提问人:Jatin kumar 提问时间:12/23/2022 最后编辑:Jatin kumar 更新时间:12/23/2022 访问量:280
Videojs 在执行 overridenative true 时停止在 MAC os safari 中流式传输
Videojs stopped streaming In MAC os safari while doing overridenative true
问:
我想获取 VHS 处理程序,以便我可以在请求之前使用播放 AES-128 内容。这就是为什么我将 overridenative true 属性传递给 VIDEOJS 播放器现在正在获得 VHS 处理程序,但它停止在播放器上播放视频。并在控制台上MEDIA_ERR_DECODE出现错误 VIDEOJS ERROR CODE:3。
以下代码用于 safari 的 DRM 配置
if (this.platform.getBrowserPlatform() === Constants.PLATFORMS.SAFARI_WEB) {
//this.playerTest.eme();
this.playerTest.src({
src: programURL,
type: this.getStreamType(channel.streams) &&
this.getStreamType(channel.streams).streamType === Constants.DASH_STREAM_TYPE ?
Constants.DASH_STREAM_SRC_TYPE : Constants.HSL_STREAM_SRC_TYPE,
keySystems: {
'com.apple.fps.1_0': {
initDataTypes: ['sinf'],
videoCapabilities: [{
contentType: 'video/mp4',
}],
getCertificate: function (emeOptions, callback) {
videojs.xhr({
url: `${cert}`,
method: 'GET',
responseType: 'arraybuffer',
headers: {
'Access-Control-Allow-Origin': '*'
}
}, (err, response, responseBody) => {
if (err) {
callback(err)
}
var responseData = new Uint8Array(responseBody);
callback(null, responseData)
})
},
getContentId: function (emeOptions, initData) {
var uint16array = new Uint16Array(initData.buffer);
var contentId = String.fromCharCode.apply(null, uint16array);
contentId = contentId.substring(contentId.indexOf('skd://') + 6);
const url = new URL(contentId);
const urlParams = new URLSearchParams(url.search);
return urlParams.get('contentId');
},
getLicense: (emeOptions, contentId, keyMessage, callback) => {
let token = localStorage.getItem('auth');
let testToken = JSON.parse(token);
//let spcMessage = encodeURI(btoa(keyMessage))
//JLO should replaced by base64EncodeUint8Array
var input = keyMessage;
var keyStr = Constants.FAIRPLAY_KEY_STR;
var output = "";
var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
var i = 0;
while (i < input.length) {
chr1 = input[i++];
chr2 = i < input.length ? input[i++] : Number.NaN; // Not sure if the index
chr3 = i < input.length ? input[i++] : Number.NaN; // checks are needed here
enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63;
if (isNaN(chr2)) {
enc3 = enc4 = 64;
} else if (isNaN(chr3)) {
enc4 = 64;
}
output += keyStr.charAt(enc1) + keyStr.charAt(enc2) +
keyStr.charAt(enc3) + keyStr.charAt(enc4);
}
//JLO should replaced by base64EncodeUint8Array
let spcMessage = output;
videojs.xhr({
url: `${this.config.baseUrl}${Constants.DRM_FAIRPLAY_LICENSE}`,
method: 'POST',
responseType: 'text',
//body: `spc=${spcMessage}&${contentId}`,
body: `{ "spc": "${spcMessage}", "assetId":"${contentId}"}`,
headers: {
"Content-Type": "application/json;charset=UTF-8",
"Authorization": `JWT ${testToken.access_token}`
}
}, (err, response, responseBody) => {
if (err) {
callback(err)
return
}
var obj = JSON.parse(responseBody);
//key = base64DecodeUint8Array(obj.ckc);
//JLO should replaced by base64DecodeUint8Array
var raw = window.atob(obj.ckc);
var rawLength = raw.length;
var array = new Uint8Array(new ArrayBuffer(rawLength));
for (let i = 0; i < rawLength; i++)
array[i] = raw.charCodeAt(i);
//JLO should replaced by base64DecodeUint8Array
callback(null, array)
})
}
}
}
})
在此处输入图像描述我实现的代码如下,用于获取 VHS 处理程序
videojs('my_player', {html5: {vhs: { overrideNative: true }}});
获取VHS处理程序并在Safari浏览器或Mac平台上流畅播放内容,在此处输入图像描述
答: 暂无答案
评论