带有DRM网址的Google Cast v3 CAF Receiver应用程序

时间:2019-09-17 11:08:12

标签: javascript google-cast drm receiver caf

我正在尝试使用v3 CAF的{​​{1}}接收器应用程序来从我的IOS应用程序投射视频。如果我使用基本的DRM接收器应用程序(默认接收器),则可以正常工作,但是当我使用v3 CAF时,它将抛出以下错误 错误

  

[20.844s] [错误] [INFO] {“ type”:“ LOAD_CANCELLED”,“ requestId”:0}

请参见下面的代码。

DRM url (dash/.mpd and licenseUrl )

const playerManager = context.getPlayerManager(); const playbackConfig = new cast.framework.PlaybackConfig(); /** Debug Logger **/ const castDebugLogger = cast.debug.CastDebugLogger.getInstance(); var manifestUri = 'https://example.domain.video/prod/drm/1/7e942940-d705-4417-b552-796e8fd25460/Media_1_20_d2aaec7102dc42c09dd54e4f00cbea412019062801270383196000/dash/manifest.mpd'; var licenseServer = 'https://wv.example.domain.com/hms/wv/rights/?ExpressPlayToken=BQALuGDeKZcAJDE2YzAwYTRkLTYwZWYtNGJiZC1hZmEzLTdhMmZhYTY2NzM5OQAAAHCZzHVjRyfs3AEgxFuwPvZsrqMndjiBPzLQ5_VUx6rJOEDD5noQmXJoVP-Va1gQzxfp9eHux15_pEr6g0RxXNZIjlsN6b7SIfpHPyS9iuPQqgvEgq5I_tV9k1lhQvKuqgpBN0Z5BtxCLwHc8xrnLbuUK6fiThcLMR4He_x38reAsumjFYg'; // setting manually licenseUrl from here playbackConfig.licenseUrl = licenseServer; playbackConfig.manifestRequestHandler = requestInfo => { requestInfo.withCredentials = true; }; playbackConfig.licenseRequestHandler = requestInfo => { requestInfo.withCredentials = true; requestInfo.headers = { // 'Content-type':'application/dash+xml', // trying this also 'Content-type':'application/octet-stream' } playbackConfig.licenseUrl = requestInfo.media.customData.licenseUrl; return playbackConfig; }; // MessageInterceptor playerManager.setMessageInterceptor( cast.framework.messages.MessageType.LOAD, request => { const error = new cast.framework.messages.ErrorData(cast.framework.messages.ErrorType.LOAD_CANCELLED); castDebugLogger.info('Error', error); if (!request.media) { error.reason = cast.framework.messages.ErrorReason.INVALID_PARAM; castDebugLogger.info('reason', error.reason); return error; } if (request.media && request.media.entity) { request.media.contentId = request.media.entity; } return new Promise((resolve, reject) => { if (!request.media) { castDebugLogger.error('MyAPP.LOG', 'Content not found'); reject(); } else { // I have passed manually data (license Url and content Id etc.) from here for testing purpose const item = new cast.framework.messages.QueueItem(); item.media = new cast.framework.messages.MediaInformation(); item.media.contentId = manifestUri; item.media.streamType = cast.framework.messages.StreamType.BUFFERED; // Trying all options of contentType item.media.contentType = "application/octet-stream"; //request.media.contentType = 'application/x-mpegurl'; //item.media.contentType = "video/mp4"; //request.media.contentType = 'video/mp4'; //request.media.contentType = 'application/dash+xml'; item.media.metadata = new cast.framework.messages.MovieMediaMetadata(); item.media.metadata.title = "Example title"; item.media.metadata.subtitle = "Example subtitle "; item.media.metadata.images = [new cast.framework.messages.Image("https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/BigBuckBunny.jpg")]; request.media = item.media; playbackConfig.protectionSystem = cast.framework.ContentProtection.WIDEVINE; resolve(request); } }); }); // start context.start({ playbackConfig: playbackConfig, touchScreenOptimizedApp: true }); LA_URL与其他在线shaka播放器配合正常。

1 个答案:

答案 0 :(得分:0)

您是否在向远程Web检查器中签入了对编码的破折号流发出加载请求时是否将网络请求发送到许可方?很有可能这将有助于找到问题所在。

可能必须将一些智能性添加到您的licenseRequestHandler中,以添加某种形式的令牌。或可能存在CORS问题。

注意:在将一些代码发布到stackoverflow之前,可能需要进行一些清理:删除无效代码,删除混乱的注释代码,提供适当的缩进。您正在浪费每个人阅读您的代码并试图处理您与世界共享的东西的大脑循环!