javascript - 带有 DRM url 的 Google cast v3 CAF Receiver 应用程序
问题描述
我正在尝试使用v3 CAF
接收器应用程序DRM
从我的 IOS 应用程序中投射视频。如果我使用基本v3 CAF
接收器应用程序(默认接收器)它工作正常,但是当我使用DRM url (dash/.mpd and licenseUrl )
它时会抛出错误错误
[ 20.844s] [错误] [INFO] {"type":"LOAD_CANCELLED","requestId":0}
请参阅下面的代码。
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
并且.mpd url
与另一位在线 shaka 播放器合作良好。
解决方案
当为编码的破折号流发出加载请求时,是否将网络请求发送给许可人,您是否检查了远程 Web 检查器?这很可能有助于找出问题所在。
可能您必须向您的 licenseRequestHandler 添加一些智能才能添加某种令牌。或者可能存在 CORS 问题。
注意:在你将一些代码发布到 stackoverflow 之前,清理一下它可能是明智的:删除死代码,删除令人困惑的注释代码,提供适当的缩进。您正在浪费每个人阅读您的代码并试图处理您与世界共享的内容的大脑周期!
推荐阅读
- python - Python Unicode 问题:将谷歌翻译结果转换为 csv
- python-3.x - 给定 csv 文件,我需要根据相似度得分打印那些最相似的句子
- python - 通过信号调用函数将默认键控参数更改为“False”。为什么?
- javascript - 基于 Promise 的序列转换为基于 Callback 的序列
- android - 使用 LiveData 的 JUnit5 测试不执行订阅者的回调
- javascript - Prettier - 使用通配符
- javascript - 为什么“背面可见性”会影响其他元素,当它们的父元素按比例变换时?
- python - 如何在不使用服务器的情况下从 HTML 页面运行 python 脚本?它应该服务于 GUI 框架的目的
- powershell - 每个域的特定 OU
- javascript - jQuery年份计算