Friday, 30 August 2013

Unable to send a json message from android app to chromecast receiver app

Unable to send a json message from android app to chromecast receiver app



Can't send a json message from my android app to the receiver app.
Android App
I've created my custom MessageStream and I am using this namespace
"com.jujuy.chromecast".
Once I get the channel from the session I attach MyCustomMessageStream to
it then and call the method to send the message.
MyCustomMessageStream cm = new MyCustomMessageStream();
channel.attachMessageStream(cm);
credentialMessage.sendTestMessage("Hello!");
Receiver App
var receiver = new cast.receiver.Receiver(
APP-ID,
["com.jujuy.chromecast"],
"",
5);
// setup the channel and listener
var mChannelHandler = new
cast.receiver.ChannelHandler("com.jujuy.chromecast"); // I think it's not
necessary to use com.jujuy.chromecast
channelHandler.addEventListener(cast.receiver.Channel.EventType.MESSAGE,
onMessage.bind(this));
channelHandler.addChannelFactory(receiver.createChannelFactory("com.jujuy.chromecast"));
// start receiver
receiver.start();
// message listener
function onMessage(event) {
document.getElementById("messageLabel").innerHTML = event.message.type;
}
After start the session () I receive this message
"failed to start application: no channel info received"
on onSessionStartFailed() method and the tv screen turns black.
I think something is wrong with the world "com.jujuy.chromecast", I saw in
other examples they use cast.receiver.RemoteMedia.NAMESPACE, I'm not sure
if I can change it with the namespace used in MyCustomMessageStream.
I saw in TicTacToe example they use a different way to get de CastDevice
object than the documentation says. Could be this the problem?
BTW My chromecast is whitelisted and I was able to run many examples
without problem.
I used a custom receiver app without problem to test play video and audio
without any problem.
Any idea? Thanks!

No comments:

Post a Comment