To start playing your video, you’ll need to create your media info object and then use the loadMedia
API. Here are the required steps.
First, define your media info object:
var mediaInfo = {
...
};
To learn how to fill your media info object correctly, click the relevant media information documentation below.
Note: For OVP players, you’ll only need to fill the entryId or referenceId (at least one is mandatory) and the KS (optional). If both entryid and referenceId are provided, the entryid has precendence. For Cloud TV players, you’ll need to provide these parameters and more. See details below.
### `mediaInfo` Structure ```js { entryId: string, ks: string, referenceId: string } ``` **Parameters** | Name | Type | Description | Possible Values | Default Value | | ------------- | -------- | ----------------------------------------------------- | --------------- | ------------- | | `entryId` | `string` | The entry ID of the media | | `referenceId` | `string` | A reference ID of the media (instead of the entry ID) | | `ks` | `string` | The KS (Kaltura Session) secret | > Note: \*\*\* Either entryId or referenceId must be supplied (if both will be supplied, the media will be loaded by mediaId) ### Examples #### Basic Usage ```js var mediaInfo = { entryId: 'YOUR_ENTRY_ID' }; ``` #### Using the KS ```js var mediaInfo = { entryId: 'YOUR_ENTRY_ID', ks: 'YOUR_KS' }; ``` #### Using the reference Id ```js var mediaInfo = { referenceId: 'YOUR_REFERENCE_ID' }; ```
### `mediaInfo` Structure
```js
{
entryId: string,
ks: string,
mediaType: string,
contextType: string,
assetReferenceType: string,
protocol: string,
fileIds: string,
streamerType: string,
urlType: string,
formats: Array
After you've created your media info, you're ready to load your media.
## Step 2 - Load the Media
To load your media, call the `loadMedia` API.
The `loadMedia` method returns a promise, since it's an asynchronous operation that accesses a server. When the promise has been resolved, you can manipulate the player as follows:
```js
player.loadMedia(mediaInfo).then(() => {
player.play();
});
```
Click [here](/kaltura-player-js/docs/api.html#loadmedia) to see the full `loadMedia` API.
### Media Options
In addition to `mediaInfo`, you can also pass media options to the `loadMedia` API. Those options will override the default options supplied from the backend or those configured in the player.
Example:
```javascript
const mediaOptions = {
...
poster: 'my/poster/url',
startTime: 30,
...
};
player.loadMedia(mediaInfo, mediaOptions);
```
## Next Step
Continue to learn how to manage player tracks, events, states and more using the development [guides](/kaltura-player-js/docs/guides.html).