I tried sending metadata from the sender to the receiver using the following code which is working fine.
const mediaInfo = new chrome.cast.media.MediaInfo(url, type);
/* --------------------------------------------- */
mediaInfo.metadata = new chrome.cast.media.GenericMediaMetadata();
mediaInfo.metadata.metadataType = chrome.cast.media.MetadataType.GENERIC;
mediaInfo.metadata.title = title;
/* --------------------------------------------- */
const request = new chrome.cast.media.LoadRequest(mediaInfo);
But now I am trying to make an api call inside the receiver itself and trying to load metadata directly right from the receiver itself.
Is there a way to do that? If so how to do that? I went through so many pages of chromecast receiver setup and couldn't find a way to do that.
Your help is largely appreciated. Thanks.
You need to use setMessageInterceptor on load and call the api and set the data on metaData and add to loadRequestData
last return the loadRequestData
const context = cast.framework.CastReceiverContext.getInstance();
const MediaMetadata = new cast.framework.messages.MediaMetadata()
const playerManager = context.getPlayerManager();
/* --------------------------------------------- */
playerManager.setMessageInterceptor(
cast.framework.messages.MessageType.LOAD, loadRequestData => {
return fetch('thirdpartyapi')
.then(response => response.json())
.then(data => {
MediaMetadata.title = 'your.Title'
MediaMetadata.subtitle = 'your.Subtitle'
/* --------------------------------------------- */
loadRequestData.media.metadata = MediaMetadata
/* --------------------------------------------- */
return loadRequestData;
})
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With