2
兴奋地终于有一段时间来尝试开发我的Chromecast,但唉......似乎无法开始。初始chromecast设置
我填写了白名单的请求,收到了确认周五的电子邮件(正好赶上了周末!),然后我开始查看样本,并根据一些我发现想让世界各地的Hello World工作。
- 配置了铬铸铁发送串行通过在Mac Chromecast应用到谷歌
- 列入白名单网址,在开发者菜单
- 验证了接收器的代码实际上是该注册声明相同的URL(从确认电子邮件中粘贴复制件并且工作)。
会发生什么是我从我的服务器或我的本地主机打开我的发件人HTML,我似乎无法得到chromecast显示(是的,我在同一网络上)。
我将日志添加到代码以验证事件消息是否正在接收,并且它没有被接收,所以我猜测它是扩展名不能验证应用程序ID的东西。
是否有我可以查看的扩展日志?
这里是发送代码:
<!DOCTYPE html>
<html data-cast-api-enabled="true">
<head>
<title>Hello sender!</title>
</head>
<body>
<div class="receiver-div">
<h3>Choose A Receiver</h3>
<ul class="receiver-list">
<li>Looking for receivers...</li>
</ul>
</div>
<button class="kill" disabled>Kill the Connection</button>
</body>
<script src="http://underscorejs.org/underscore-min.js"></script>
<script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
<script>
var cast_api,
cv_activity,
receiverList,
$killSwitch = $('.kill');
console.log("initializing script");
window.addEventListener('message', function(event) {
console.log('Message received of type'+event.data.event);
if (event.source === window && event.data &&
event.data.source === 'CastApi' &&
event.data.event === 'Hello') {
initializeApi();
}
});
initializeApi = function() {
console.log('Initialize API called');
if (!cast_api) {
console.log("no cast api yet")
cast_api = new cast.Api();
cast_api.addReceiverListener('myidstring here', onReceiverList);
}
};
onReceiverList = function(list) {
console.log('on receiverlist called');
if (list.length > 0) {
receiverList = list;
$('.receiver-list').empty();
receiverList.forEach(function(receiver) {
$listItem = $('<li><a href="#" data-id="' + receiver.id + '">' + receiver.name + '</a></li>');
$listItem.on('click', receiverClicked);
$('.receiver-list').append($listItem);
});
}
};
receiverClicked = function(e) {
e.preventDefault();
var $target = $(e.target),
receiver = _.find(receiverList, function(receiver) {
return receiver.id === $target.data('id');
});
doLaunch(receiver);
};
doLaunch = function(receiver) {
if (!cv_activity) {
var request = new cast.LaunchRequest('still my id string here', receiver);
$killSwitch.prop('disabled', false);
cast_api.launch(request, onLaunch);
}
};
onLaunch = function(activity) {
if (activity.status === 'running') {
cv_activity = activity;
cast_api.sendMessage(cv_activity.activityId, 'charz', {type: 'HelloWorld'});
}
};
$killSwitch.on('click', function() {
cast_api.stopActivity(cv_activity.activityId, function(){
cv_activity = null;
$killSwitch.prop('disabled', true);
});
});
</script>
</html>
是被记录的唯一的事情是“初始化脚本”行。
谢谢你提前,
CR。
编辑: 我将标志着阿里的答案回答,因为他把我的道路上进行修复: 的事实,调试意味着白名单已经做了,让我看看配置就在我身边:
- file://网址不起作用
- 当我在本地设置自己的web服务器时,localhost/sender.html立即生效。
- 白名单必须是明确的,不包括协议(显然)。我曾将我的网址列入白名单:
http://myserver/mypath/sender.html
,但没有起作用,最后添加了myserver/mypath/sender.html
使其完美无缺。
也许文档可能会更新,以反映这??
是的这是有效的,因此本质上该设备被列入白名单。但它不会触发“消息”事件。 – cromestant
感谢您的帮助,阿里通过电子邮件在任何时间帮助了很多! – cromestant
我遇到同样的问题,以您的方式设置网址,但没有帮助。找到我的设备IP并处于开发模式。我没有看到在开发者菜单中的任何地方将网址列入白名单......是我错过了什么? –