我指的是Google给出的这个示例(特别是sender.js文件)(https://github.com/googlecast/CastMediaPlayerStreamingDRM/blob/master/sender.js)。我正在尝试播放http://storage.googleapis.com/wvmedia/cenc/tears.mpd文件,该文件是DRM,我正在传递许可证URL http:// widevine-proxy.appspot.com/proxy在示例中的sender.js文件中。
我的发件人是Android(我正在使用CastCompanionLibrary)。这是我在Android中发送它的方式:
mCastManager.sendDataMessage("http://playready.directtaps.net/pr/svc/rightsmanager.asmx");
mCastManager.startCastControllerActivity(LocalPlayerActivity.this, media, 0, true);
这就是我在自定义接收器中收到许可证URL的方式:
messageBus = castReceiverManager.getCastMessageBus(--NAME SPACE--);
messageBus.onMessage = function(event) {
console.log(event['data']);
licenseURL = event['data'];
console.log(licenseURL);
}
到目前为止,我已调试并且licenseURL设置为Android发件人发送的许可证URL。它正在接收器中正确接收licenseURL。然后在我的onLoad方法中,我执行以下操作。
mediaManager.onLoad = function(event) {
if(mediaPlayer !== null) {
mediaPlayer.unload(); // Ensure unload before loading again
}
if (event.data['media'] && event.data['media']['contentId']) {
var url = event.data['media']['contentId'];
mediaHost = new cast.player.api.Host({
'mediaElement': mediaElement,
'url': url
});
mediaHost.onError = function (errorCode) {
console.error('### HOST ERROR - Fatal Error: code = ' + errorCode);
if (mediaPlayer !== null) {
mediaPlayer.unload();
}
}
if(licenseURL){
console.log("##License URL is not null");
mediaHost.licenseURL = licenseURL;
}
var initialTimeIndexSeconds = event.data['media']['currentTime'] || 0;
var protocol = null;
var parser = document.createElement('a');
parser.href = url;
var ext = ext = parser.pathname.split('.').pop();
if (ext === 'm3u8') {
protocol = cast.player.api.CreateHlsStreamingProtocol(mediaHost);
} else if (ext === 'mpd') {
protocol = cast.player.api.CreateDashStreamingProtocol(mediaHost);
} else if (ext === 'ism/') {
protocol = cast.player.api.CreateSmoothStreamingProtocol(mediaHost);
}
console.log('### Media Protocol Identified as ' + ext);
if (protocol === null) {
mediaManager['onLoadOrig'](event); // Call on the original callback
} else {
mediaPlayer = new cast.player.api.Player(mediaHost);
mediaPlayer.load(protocol, initialTimeIndexSeconds);
}
}
}
但是当我这样做时,我收到了错误:
XMLHttpRequest cannot load http://storage.googleapis.com/wvmedia/cenc/tears.mpd. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://dl.dropboxusercontent.com' is therefore not allowed access.
### HOST ERROR - Fatal Error: code = 3
我暂时在dropbox公共文件夹上托管接收器。关于我做错了什么想法?