我有两组代码。我的接收者和发送者应用程序。我对此还不陌生,它给了我很多问题。首先,最重要的是,我使用的是旧版chrome版本,这就是我的应用程序的运行方式。 当我单击以投射给定的应用程序时,设备列表确实会下拉,但是当我单击以投射至设备时,我只能在连接到该铬合金投射器的电视上看到白屏,然后一分钟左右,该应用程序将停止投射并显示我出现“投放失败”错误消息。
从我的理解来看,index.html文件是我所有用于初始化API的js脚本的地方,并要求接收方代码上的会话是我具有以下所有代码的地方:
<div id="containerDiv" ></div>
<div id="messageDiv"></div>
<script type="text/javascript"
src="//www.gstatic.com/cast/sdk/libs/receiver/2.0.0/cast_receiver.js"/>
<!-- -
<script type="text/javascript"
src="//www.gstatic.com/cast/sdk/libs/caf_receiver/v3/cast_receiver_framework.js"></script>
//www.gstatic.com/cast/sdk/libs/receiver/2.0.0/cast_receiver.js
<!--
<script type="text/javascript" src="js\debug.js"></script> -->
<script type="text/javascript">
window.onload = function() {
cast.receiver.logger.setLevelValue(0);
window.castReceiverManager = cast.framework.CastReceiverContext.getInstance();
console.log('Starting Receiver Manager');
// handler for the 'ready' event
castReceiverManager.onReady = function(event) {
console.log('Received Ready event: '
+ JSON.stringify(event.data));
window.castReceiverManager
.setApplicationState("Application status is ready...");
};
// handler for 'senderconnected' event
castReceiverManager.onSenderConnected = function(event) {
console.log('Received Sender Connected event: ' + event.data);
console
.log(window.castReceiverManager.getSender(event.data).userAgent);
};
// handler for 'senderdisconnected' event
castReceiverManager.onSenderDisconnected = function(event) {
console
.log('Received Sender Disconnected event: '
+ event.data);
if (window.castReceiverManager.getSenders().length == 0) {
window.open();
}
};
// handler for 'systemvolumechanged' event
castReceiverManager.onSystemVolumeChanged = function(event) {
console.log('Received System Volume Changed event: '
+ event.data['level'] + ' ' + event.data['muted']);
};
// create a CastMessageBus to handle messages for a custom namespace
window.messageBus = window.castReceiverManager
.getCastMessageBus('urn:x-cast:com.theWebsite');
// handler for the CastMessageBus message event
window.messageBus.onMessage = function(event) {
console.log('Message [' + event.senderId + ']: ' + event.data);
// display the message from the sender
displayText(event.data);
// inform all senders on the CastMessageBus of the incoming message event
// sender message listener will be invoked
window.messageBus.send(event.senderId, event.data);
}
// initialize the CastReceiverManager with an application status message
window.castReceiverManager.start({
statusText : "Application is starting"
});
console.log('Receiver Manager started');
};
// utility function to display the text message in the input field
function displayText(text) {
console.log(text);
panelSetup(text);
//document.getElementById("messagePanelDiv").innerHTML = text;
//$$('#messagePanelDiv').set('html', text);
window.castReceiverManager.setApplicationState(text);
};
</script>
</body>
这里的问题是什么,因为我相信我的index.html页工作正常,因为我正在建立连接,否则当我单击按钮以投射文件时,将无法看到设备列表。但是连接并没有完全通过,这意味着它实际上从未连接。它说它已经连接,一分钟左右它说它没有连接。
基本上,我想知道是否检查接收方代码吗?还是只是我的索引文件没有正确初始化API? 我还同时连接了新旧库,我认为新的libar会有所帮助,但不是这样
任何建议都有帮助。