デスクトップ Chrome から Chromecast レシーバーに簡単なカスタム メッセージを送信できる、基本的な Chromecast アプリのセットアップを取得しようとしています。デバイスはホワイトリストに登録されており、アプリ ソースはホワイトリスト登録プロセス中に指定された URL に置かれています。さらに、正しい API_ID が使用されており、NAMESPACE は受信側と送信側のアプリで同じです。
受信アプリが読み込まれますが、その直後に次のようになります。
[ 0.230s] [goog.net.WebSocket] The WebSocket disconnected unexpectedly: undefined
これにより、カスタム メッセージを Chromecast に送信できなくなっているようです。
送信側アプリから、デバイスを見つけて接続し、受信側アプリを起動できます。また、送信側で stopActivity() 呼び出しを適切に切断することもできます。
受信機の設定は次のとおりです。
var receiver = new cast.receiver.Receiver(APP_ID, NAMESPACE);
var channelHandler = new cast.receiver.ChannelHandler(NAMESPACE);
channelHandler.addChannelFactory(receiver.createChannelFactory(NAMESPACE));
channelHandler.addEventListener('error', function($e){
console.log('JAC - Error!');
});
channelHandler.addEventListener('open', function($e){
console.log('JAC - OnOpen!');
});
channelHandler.addEventListener('message', function($e){
console.log('JAC - Message: ' + $e.type);
});
receiver.start();
Chromecast デバイスからの完全なログは次のとおりです (実際の appId は削除されています)。
[ 0.027s] [cast.receiver.ChannelHandler] New channel factory added: MY-APP-ID to heartbeatChannelHandler
cast_receiver.js:66
[ 0.088s] [cast.receiver.ChannelHandler] New channel factory added: receiverTest1: MY-APP-ID to receiverTest1
cast_receiver.js:66
[ 0.094s] [cast.receiver.ConnectionService] Open connection service websocket: url=ws://localhost:8008/connection
cast_receiver.js:66
[ 0.098s] [goog.net.WebSocket] Opening the WebSocket on ws://localhost:8008/connection
cast_receiver.js:66
[ 0.104s] [cast.receiver.Receiver] Receiver started.
cast_receiver.js:66
[ 0.142s] [goog.net.WebSocket] WebSocket opened on ws://localhost:8008/system/control
cast_receiver.js:66
[ 0.153s] [cast.receiver.ChannelOverWebSocket] Dispatch OPEN event to ws://localhost:8008/system/control
cast_receiver.js:66
[ 0.159s] [cast.receiver.Channel] Dispatch OPEN event to ws://localhost:8008/system/control
cast_receiver.js:66
[ 0.164s] [cast.receiver.Platform] Platform channel is open: ws://localhost:8008/system/control
cast_receiver.js:66
[ 0.208s] [goog.net.WebSocket] WebSocket opened on ws://localhost:8008/connection
cast_receiver.js:66
[ 0.212s] [cast.receiver.ConnectionService] Got event: d
cast_receiver.js:66
[ 0.222s] [goog.net.WebSocket] The WebSocket on ws://localhost:8008/connection closed.
cast_receiver.js:66
[ 0.225s] [cast.receiver.ConnectionService] Got event: a
cast_receiver.js:66
[ 0.230s] [goog.net.WebSocket] The WebSocket disconnected unexpectedly: undefined
この問題の助けをいただければ幸いです。ありがとう!