我从https://github.com/googlecast/cast-chrome-sender-helloworld获取了 cast-chrome-sender-helloworld 示例应用程序并插入了我的 APP ID。APP ID 与指向的 URL 相关联,http://<server>/<path>/chromecast
请注意缺少结尾“/”或“.html”,这是我故意这样做的,因为它基本上是一个处理接收器的 servlet。
我的发件人应用程序将请求发送到 chromecast 棒。使用 Chrome 中的调试器,我可以看到启动与我的 APP ID 关联的特定应用程序的请求已收到,并且棒尝试从上述 URL 加载接收应用程序。但是,我看到 HTTP GET 请求已执行,但它的状态是“待定”一段时间(我猜)它超时。
无法加载接收方应用程序是否是由于列入白名单的 URL 没有“.html”?
** 9 月 27 日编辑
我仍然看到 Chromecast 浏览器发出正确的请求 URL,但它“挂起”,网络状态消息“待定”。没有请求命中我的 apache 服务器。如果我使用笔记本电脑在同一个 wifi 网络上发出相同的请求,那么我会得到以下正确答案(使用 CURL):
curl -vvv http://server.domain.com/path/device/chromecast
* About to connect() to server.domain.com port 80 (#0)
* Trying 192.168.1.42...
* connected
* Connected to server.domain.com (192.168.1.42) port 80 (#0)
> GET /path/device/chromecast HTTP/1.1
> User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8y zlib/1.2.5
> Host: server.domain.com
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Fri, 27 Sep 2013 06:46:23 GMT
< Server: Apache-Coyote/1.1
< Content-Type: text/html;charset=ISO-8859-1
< Content-Length: 1850
< Set-Cookie: JSESSIONID=81A3A6184F014A7FBEC60C0B6375E8B0; Path=/client-portal/; HttpOnly
<
<!DOCTYPE html>
<html>
<head>
<script src="https://www.gstatic.com/cast/js/receiver/1.0/cast_receiver.js">
</script>
<script type="text/javascript">
cast.receiver.logger.setLevelValue(0);
// Initialize and start the media playing receiver
var receiver = new cast.receiver.Receiver(
'REPLACED_WITH_MY_APPID',
[cast.receiver.RemoteMedia.NAMESPACE],
"",
5);
var remoteMedia = new cast.receiver.RemoteMedia();
remoteMedia.addChannelFactory(
receiver.createChannelFactory(cast.receiver.RemoteMedia.NAMESPACE));
receiver.start();
window.addEventListener('load', function() {
var elem = document.getElementById('vid');
remoteMedia.setMediaElement(elem);
var checkStatus = function() {
var status = document.getElementById('status');
var st = remoteMedia.getStatus()['state'];
if( st == 0 || remoteMedia.getStatus()['current_time'] == 0 ) {
status.style.display = 'block';
}
else {
if( st == 1 && remoteMedia.getStatus()['current_time'] > 0 ) {
status.innerHTML = 'Paused...';
status.style.display = 'block';
}
else {
status.innerHTML = remoteMedia.getStatus()['current_time'];
status.style.display = 'none';
elem.style.display = 'block';
}
}
}
setInterval(checkStatus, 1000);
});
</script>
<title>Media Player App</title>
</head>
<body>
<video id="vid"
style="position:absolute;top:0;left:0;height:100%;width:100%"></video>
<div id="status" style="display:none; font-size:300%; position:absolute;top:40%;left:40%;">
<img src="/images/chrome_loading.gif" width="60%">
</div>
</body>
* Connection #0 to host server.domain.com left intact
</html>* Closing connection #0f
在重新加载“大脑冻结”屏幕之前,调试器只显示以下内容: