無法從我的Android應用程序發送JSON消息到接收器應用程序。無法發送從Android應用程序的JSON消息到Chromecast接收器應用程序
Android應用
- 我已經建立了我的自定義MessageStream,我用這個命名空間 「com.jujuy.chromecast」。
一旦我從會話中獲得通道,我將MyCustomMessageStream附加到它然後調用方法來發送消息。
MyCustomMessageStream cm = new MyCustomMessageStream(); channel.attachMessageStream(cm);
cm.sendTestMessage(「Hello!」);
接收機應用
var receiver = new cast.receiver.Receiver(
APP-ID,
["com.jujuy.chromecast"],
"",
5);
var channelHandler = 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"));
receiver.start();
// message listener
function onMessage(event) {
document.getElementById("messageLabel").innerHTML = event.message.type;
}
啓動會話()我收到此消息 後「啓動失敗的應用程序:沒有信道信息接收到的」 上onSessionStartFailed()方法和在電視屏幕變黑。
我覺得有什麼不妥世界「com.jujuy.chromecast」,我在他們使用cast.receiver.RemoteMedia.NAMESPACE其他例子中看到的,我不知道如果我能在使用的命名空間更改MyCustomMessageStream。
我在TicTacToe示例中看到,他們使用不同的方法來獲取de CastDevice對象,而不是文檔說的。可能是這個問題?
我的Chromecast被列入白名單,並且我能夠正常運行很多示例。
我使用自定義的接收器應用程序來測試播放視頻和音頻。任何想法?
在你的'MyCustomMessageStream'類的構造函數中,是否調用了'super(「com.jujuy.chromecast」);'爲超級'MessageStream'類設置命名空間? – anthonylawson