1

I need help, in my custome receiver Chromecast app, I can not fetch media metadata with which the app was initialized.

I loaded media like this, after sucesful session request:

    var mediaInfo = new chrome.cast.media.MediaInfo('https://wse-wowaza01.playne.tv:443/webdrmorigin/1042a2W.smil/manifest.mpd');
    mediaInfo.customData = {
        "userId": "mislav",
        "sessionId": "39BE906248F9F5C4A93C7",
        "merchant": "playnr"
    };
    mediaInfo.metadata = new chrome.cast.media.MovieMediaMetadata();
    mediaInfo.metadata.metadataType = chrome.cast.media.MetadataType.MOVIE;
    var img = new chrome.cast.Image('https://ottservice.playnr.tv/OTTranscoderHttps/get?url=http%asd9.168%2f20664_5b8df65c-67ff-4f13-b90d-b28c37f2310c.jpg&w=224&h=126');
    mediaInfo.metadata.images = [img];
    mediaInfo.contentType = 'video/mp4';
    var request = new chrome.cast.media.LoadRequest(mediaInfo);
    //this.playerState = this.PLAYER_STATE.LOADING;
    this.session.loadMedia(request,
        this.onLoadMediaSuccess.bind(this, 'loadMedia'),
        this.onLoadMediaFailure.bind(this)
    );

How can i access that metadata in receiver app? I tried with

cast.receiver.MediaManager.getInstance() 

but no luck. Are there any steps before need to code on receiver to make data available?

Samane
  • 500
  • 7
  • 23
MIslavMIslav
  • 93
  • 1
  • 8

2 Answers2

2

Thank you for help, pointed me in right direction.

Got it working, this was the problem. I am using 3rd party DMR javascript plugin for content protection. It encapsulates cast_receiver and had already instantiated MediaManager & ReceiverManager, i didnt noticed that. Then i instantiated new mediaManager, but it wasn bound to any data. Pause/play event were all handled by plugins mediamanager instance, so my instance was useless. As soon i referenced allready instantiated mediamanager, data is there and his events are working. Same with receiver manager, i started instance that was already started and problems....SO conclusion, i dont need to instantiate any, DRM plugin takes care of everything, just need to override his event handlers

MIslavMIslav
  • 93
  • 1
  • 8
1

Depends on where on the receiver you want t access that info. For example, in a number of callbacks, you have an "event" of type cast.receiver.MediaManager.Event, from which you can get, for example, a cast.receiver.MediaManager.LoadRequestData object via event.data. Then this data object has your customData (data.customData)

Ali Naddaf
  • 16,951
  • 2
  • 21
  • 28
  • 1
    How to hit f.e. this.mediaManager.onPause event handler? Or some similar? Can you provide me some example please? I only managed to hit event handlers for events raised by – MIslavMIslav Oct 03 '15 at 20:27
  • You can take a look at https://developers.google.com/cast/docs/custom_receiver#media which tells you how to override certain callbacks and how to capture events. The reference receiver sample is also something that is useful to look at: https://github.com/googlecast/Cast-Player-Sample – Ali Naddaf Oct 03 '15 at 21:21
  • I managed to hook to mediamanager events, but only when my receiver manager is started. If i dont start recetiver manager, my video loads & streams, and then i'm not getting any mediamanager events. Only from mediaelement. But when I start receiver manager, i got event from mediamanager, but stream wont play I get onLoadMetadataError. What can be the problem? When i start receiver manager, i got errors like The WebSocket disconnected unexpectedly: undefined. – MIslavMIslav Oct 04 '15 at 10:20
  • If you want properly use Cast SDK, you need to start and use the MediaManager. As I said earlier, you may want to grab the reference receiver as your starting point and then update that to add the additional functionalities that you may need. – Ali Naddaf Oct 04 '15 at 16:46