简体   繁体   English

Chromecast DRM示例

[英]Chromecast DRM example

I am referring to this example given by Google (sender.js file in particular) ( https://github.com/googlecast/CastMediaPlayerStreamingDRM/blob/master/sender.js ). 我指的是Google给出的这个示例(尤其是sender.js文件)( https://github.com/googlecast/CastMediaPlayerStreamingDRM/blob/master/sender.js )。 I am trying to play the http: //storage.googleapis.com/wvmedia/cenc/tears.mpd file which is DRM and I am passing in the license URL http:// widevine-proxy.appspot.com/proxy as defined in the sender.js file in the example. 我正在尝试播放http://storage.googleapis.com/wvmedia/cenc/tears.mpd文件(即DRM),并且我按照定义传递了许可URL http:// widevine-proxy.appspot.com/proxy在示例中的sender.js文件中。

My sender is Android (I am using the CastCompanionLibrary). 我的发件人是Android(我正在使用CastCompanionLibrary)。 This is how I am sending it in Android: 这是我在Android中发送的方式:

mCastManager.sendDataMessage("http://playready.directtaps.net/pr/svc/rightsmanager.asmx");
mCastManager.startCastControllerActivity(LocalPlayerActivity.this, media, 0, true);

This is how I am receiving the license URL in the my custom receiver: 这是我在自定义接收方中接收许可证URL的方式:

messageBus = castReceiverManager.getCastMessageBus(--NAME SPACE--);

messageBus.onMessage = function(event) {

        console.log(event['data']);
        licenseURL = event['data'];
        console.log(licenseURL);

    }

So far I have debugged and licenseURL is set to the license URL sent by the Android sender. 到目前为止,我已经调试好了,将licenseURL设置为Android发送者发送的许可证URL。 It is receiving the licenseURL properly in the receiver. 它在接收器中正确接收了licenseURL。 Then in my onLoad method I do the following. 然后在我的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);
            }
        }
    }

But when I do this I am getting the error: 但是当我这样做时,我得到了错误:

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 

I am hosting the receiver temporarily on dropbox public folder. 我将接收器临时托管在保管箱公用文件夹上。 Any ideas as to what I am doing wrong? 关于我在做什么错的任何想法吗?

Your server that is hosting your media is not sending CORS headers which is required. 承载媒体的服务器未发送所需的CORS标头。 You need to add those, see this document , section Using Cross-Origin Resource Sharing (CORS). 您需要添加它们,请参阅本文档的“使用跨域资源共享(CORS)”部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM