The HTML5 player comes with a default Chromecast receiver implementation, however, you can use your own receiver by overriding the default Application ID. This is done by setting the appId option on the Chromecast button:
options['controlBar'] = {
'chromeCastButton': {
'appId': receiverAppId
}
};The receiver is compliant with the default chromecast receiver API unless otherwise stated. For information on how to build a sender and other functionality not described here. See https://developers.google.com/cast/docs/sender_apps
Loading Media
To load media on the receiver, we opted out of casting simple content-urls. This to ensure we can retrieve proper playtokens and make it compatible with any sender, regardless of content playback. In order to cast any media, the media has to be available in the DASH/CENC format.
Loading media is done by the following methods
GCKMediaControlChannel:loadMedia (iOS)
RemoteMediaPlayer.load (android)
For both platforms, the MediaInfo payload should contain the following properties in the custom data
{
ericssonexposure: {
customer: 'customer',
businessUnit: 'businessUnit',
sessionToken: 'sessionToken', // Valid API session that has access to the requested media
exposureApiURL: 'apiUrl'
},
assetId: 'assetId', // identifier of media to cast
programId: 'programId', // optional
}The receiver will request the proper media from the API itself. If none is found a castError is triggered containing more information.
Custom Messaging
When connected to the receiver messages can be send over the namespace: urn:x-cast:com.ericsson.cast.receiver. All messages to and from the receiver will be send over this namespace.
Embedded tracks
Embedded tracks are broadcasted to all connected senders when a sender send refreshcontrols message, or when subtitles/audio tracks change or period change.
If the stream has multi periods the audio and text tracks can change even id's
{
type: 'tracksupdated',
data: {
tracksInfo: {
activeTrackIds: [0, 1] // array containing all active tracks
tracks: [
label: 'label', // textual representation of track
type: '(text|audio)', // Track type, either text or audio
trackId: 0, // Track identifier
language: 'sv' // language identifier
]
}
}
}- Use the 'activeTrackIds' property to display on the sender which track is currently active on the receiver.
- If only one audiotrack is available, no audiotracks are broadcasted. Instead the default track is used.
- If no subtitle is currently active and only one audiotrack is available, the activeTrackIds array can be null
- The information send in this event is always leading, in the case multiple senders modify tracks at the same time. always use the last received message to display the correct information to the user
Changing subtitles
To update which subtitle track is being displayed on the receiver, the following messages can be send
// Showing a texttrack
{
type: 'showtexttrack',
data: {
language: en // language code
}
}
// Hiding subtitles
{
type: 'hidetexttrack'
}After changing subtitles all connected senders (including the sender that made the request) receive a 'tracksupdated' message containing updated information about the embedded tracks.
Changing audiotracks
To update which audio track is being used on the receiver, the following messages can be send
// Enabling an audiotrack
{
type: 'enableaudiotrack',
data: {
language: en // language code
}
}After changing audiotracks all connected senders (including the sender that made the request) receive a 'tracksupdated' message containing updated information about the embedded tracks.
Refresh Controls
After joining a session, it might be necessary to request the constrols' status (volume level, timeshift enabled, tracks). By sending this message to the receiver, it will then answer with updated controls.
// Requesting controls update
{
type: 'refreshcontrols',
data: {
}
}Start Time
To start casting a media from a position other than 0, it is possible to set the currentTime attribute in the LoadRequest object (found in the Chromecast API).
// Setting start time
var loadRequest = new window.chrome.cast.media.LoadRequest(mediaInfo);
loadRequest.currentTime = startTime;Title, Subtitle and Artwork
It is possible to send movie metadata along with the request: movie title, subtitle and image(s).
var assetMetadata = new window.chrome.cast.media.MovieMediaMetadata();
assetMetadata.title = '<MovieTitle>';
assetMetadata.subtitle = '<MovieSubtitle>';
assetMetadata.images = [new window.chrome.cast.Image('<ImageUrl>')];
mediaInfo.metadata = assetMetadata;Other relevant messages sent by the EMP Receiver
timeShiftEnabled - Signals whether timeshift is enabled in the controls or not.
// Timeshift property
{
type: 'timeShiftEnabled',
data: (boolean)
}volumechange - signals a change in the volume status.
// Volume changed property
{
type: 'volumechange',
data: {
volume: (number),
muted: (boolean)
}
}durationchange - signals a change in the duration of the media being played.
// Duration change property (important for growing media)
{
type: 'durationchange',
data: (number)
}
EMP Html5 Player