getMedia()
Gets media data by slug or ID.
Signature
const media = await window.FairShareSDK.getMedia(identifier);
Parameters
| Parameter | Type | Description |
|---|---|---|
identifier | string | Media slug or ID |
Returns
Promise<Media> — The media object.
Media Object:
| Property | Type | Description |
|---|---|---|
id | number | Media ID |
title | string | Media title |
description | string | Media description |
thumbnail_url | string | Thumbnail image URL |
media_type | string | Type of media (video, image, etc.) |
duration | number | Duration in seconds (for video) |
Example
// Get media by slug const media = await window.FairShareSDK.getMedia("welcome-video"); console.log('Title:', media.title); console.log('Type:', media.media_type); console.log('Thumbnail:', media.thumbnail_url);
Get by ID
const media = await window.FairShareSDK.getMedia("12345");
Related
- Media — Media component
- getLibrary — Get library/playlist data