MediaLoadRequestUtils
Converts a CLVideo component or a PlayerConfiguration object into a MediaLoadRequest object that is used to load media to Chromecast. The MediaLoadRequest is part of the react-native-google-cast library.
Constructors
new MediaLoadRequestUtils()
new MediaLoadRequestUtils(): MediaLoadRequestUtils
Methods
fromPlayerConfiguration()
static fromPlayerConfiguration(playerConfiguration, drmConfiguration?): default
Converts a PlayerConfiguration component to a MediaLoadRequest object, convenient when Chromecast is connected and there is no local playback.
An optional DRM configuration can be provided to override the one in the player configuration. This is particularly useful if the DRM configuration contains authentication tokens that may have expired at the time of casting.
Before passing the MediaLoadRequest object to the loadMedia
,
you can add your custom data to the mediaLoadRequest.mediaInfo.customData
object.
Later, you can retrieve this data from the session by accessing the mediaStatus.mediaInfo.customData
object.
Parameters
Parameter | Type | Description |
---|---|---|
playerConfiguration | PlayerConfiguration | The player configuration |
drmConfiguration ? | DrmTodayConfiguration | DrmTodayOnboardConfiguration | CustomDrmConfiguration | The optional DRM configuration |
Returns
The MediaLoadRequest object
Exmple
const mediaLoadRequest = await MediaLoadRequestUtils.fromPlayerConfiguration(playerConfiguration);
// Add your custom data to the `mediaLoadRequest.mediaInfo.customData` object
await castSession.getClient().loadMedia(mediaLoadRequest);
fromVideoComponent()
static fromVideoComponent(videoComponent, drmConfiguration?): Promise<default>
Converts a CLVideo component to a MediaLoadRequest object, convenient when Chromecast is not connected and there is local playback in progress.
This MediaLoadRequest contains the player configuration as well as the current player state, position, audio track and text track. An optional DRM configuration can be provided to override the one in the player configuration. This is particularly useful if the DRM configuration contains authentication tokens that may have expired at the time of casting.
Before passing the MediaLoadRequest object to the loadMedia
,
you can add your custom data to the mediaLoadRequest.mediaInfo.customData
object.
Later, you can retrieve this data from the session by accessing the mediaStatus.mediaInfo.customData
object.
Parameters
Parameter | Type | Description |
---|---|---|
videoComponent | CLVideo | The video component |
drmConfiguration ? | DrmTodayConfiguration | DrmTodayOnboardConfiguration | CustomDrmConfiguration | The optional DRM configuration |
Returns
The media load request
Exmple
const mediaLoadRequest = await MediaLoadRequestUtils.fromVideoComponent(videoComponent);
// Add your custom data to the `mediaLoadRequest.mediaInfo.customData` object
await castSession.getClient().loadMedia(mediaLoadRequest);