更新:我将我的视频信息插入此https://bitmovin.com/demos/drm并且播放没有问题。这让人相信这不是 CORS 问题
我已经尝试了很多次,试图让我们的 DRM-ed 视频在 chromecast 上播放。看起来它可以很好地运行非 DRM 视频,即使我弄乱了元数据(显然这不应该对视频产生影响)
const playbackConfig = new cast.framework.PlaybackConfig();
playbackConfig.licenseUrl = DRM_LICENSE
playbackConfig.protectionSystem = cast.framework.ContentProtection.WIDEVINE;
playbackConfig.licenseRequestHandler = requestInfo => {
requestInfo.withCredentials = true;
};
我用我的实际视频拦截了发送的请求:
playerManager.setMessageInterceptor(
cast.framework.messages.MessageType.LOAD, loadRequestData => {
loadRequestData.media.contentId = "videoUrl.m3u8"
loadRequestData.media.contentType = 'application/x-mpegurl'
var metadata = new
cast.framework.messages.GenericMediaMetadata();
metadata.title = 'robocop in action';
metadata.subtitle = 'robocop';
loadRequestData.media.metadata = metadata
loadRequestData.media.HlsSegmentFormat = cast.framework.messages.HlsSegmentFormat.FMP4;
loadRequestData.media.HlsVideoSegmentFormat = cast.framework.messages.HlsVideoSegmentFormat.FMP4;
console.log(loadRequestData)
return loadRequestData;
});
最终,一切都汇集到这个最终功能中:
context.start({playbackConfig : playbackConfig})
让 DRM 内容在 Chromecast 上运行究竟需要什么?
谢谢
原来我需要将 CORS 标头传递到我的播放配置中:
const playbackConfig = new cast.framework.PlaybackConfig();
playbackConfig.licenseUrl =
"DRM-LICENSE-URL";
playbackConfig.protectionSystem = cast.framework.ContentProtection.DRMMETHOD;
playbackConfig.licenseRequestHandler = requestInfo => {
requestInfo.withCredentials = true;
requestInfo.headers = [
{
"origin": ["*"],
"responseHeader": ["Content-Type"],
"method": ["GET", "HEAD"],
"maxAgeSeconds": 86400
}
];
};