0
votes

I am developing a Custom Chromecast Receiver App. Is it possible to launch media via the Cast Message Bus? I'm aware that it's not the best practice and there is already a mechanism to launch media via the GCKMediaControlChannel

I'm using the https://github.com/googlecast/CastReferencePlayer as a starting point.

I'm sending the text message (containing the Media Info JSON) via my sender like this:

[_castServiceChannel sendTextMessage:mediaInfoJSON];

The JSON is being received on the receiver and I am then trying to launch the media player like so:

sampleplayer.CastPlayer.prototype.loadVideo_(message);

But I'm not initialising the media player properly. Does anyone have any ideas?

1

1 Answers

0
votes

The problem for me was that I couldn't launch the video because:

  1. loadVideo_() was the wrong method, I should be using load()
  2. The player was never initialised properly when receiving the cast messages.

My solution was to separate the cast message bus messages from the player. So in my player.html, I init the cast message bus. When I receive JSON of the media that I want to play, I init player.js from player.html like so:

//receive message to play -> pass media through
var player = document.getElementById('player');
new sampleplayer.CastPlayer(player).start();

then in

sampleplayer.CastPlayer.prototype.start = function() {
  this.load(JSON.parse(message));
};

Only thing that's a problem is that the Media Manager is never properly initialised in the Cast Receiver app. So this means that I can't capture RCU events properly. Any ideas why this could be happening?