我为Chromecast创建了自定义发件人和收件人应用程序。发件人应该通过网络发送网址(破折号mpd)。接收器应该创建一个视频元素,并在收到破折号mpd url时创建一些与视频元素交互的额外文件。
发件人我正在这样做:
var request = new cast.LaunchRequest(APP_ID, receiver);
request.parameters = params;
cast_api.launch(request, onLaunch);
其次是:
var request = new cast.MediaLoadRequest("http://dash.edgesuite.net/envivio/dashpr/clear/Manifest.mpd");
request.parameters = params;
cast_api.loadMedia(cv_activity.activityId, request, onLoad);
然后在接收器中我有:
var receiver = new cast.receiver.Receiver(APP_ID, [cast.receiver.RemoteMedia.NAMESPACE]);
var rampHandler = new cast.receiver.RemoteMedia();
rampHandler.addChannelFactory(receiver.createChannelFactory(cast.receiver.RemoteMedia.NAMESPACE));
rampHandler.onOpen = onOpen;
rampHandler.onMessage = onMessage;
rampHandler.onLoad = onLoad;
rampHandler.onInfo = onInfo;
rampHandler.onPlay = onPlay;
rampHandler.onStop = onStop;
rampHandler.onEnded = onEnded;
rampHandler.onMetadataLoaded = onMetadataLoaded;
rampHandler.onLoadMetaDataError = onLoadMetaDataError;
rampHandler.onVolume = onVolume;
当我启动接收器时,onOpen和onMessage会被触发一次。我打电话给api.loadMedia后似乎没有任何事情发生。根据我的阅读,似乎api正在访问RemoteMedia应响应的RAMP调用。在调用api.loadMedia之后,我期待onLoad或onMessage被触发..但没有任何反应。 Chromecast调试器中根本没有任何痕迹。
答案 0 :(得分:-1)
您必须更改对象原型:
cast.receiver.RemoteMedia.prototype.onLoad = onLoad