README
加密MP4播放插件
安装
npm i xgplayer
npm i xgplayer-encrypt-mp4
使用方式
通过 kid 播放
import 'xgplayer'
import Mp4Player from 'xgplayer-encrypt-mp4'
let player = new Mp4Player({
id: 'vs',
url: 'xxx',
vid: 'xxx',
kid: 'xxx'
});
通过 keyValue 播放
import 'xgplayer'
import Mp4Player from 'xgplayer-encrypt-mp4'
let player = new Mp4Player({
id: 'vs',
url: 'xxx',
vid: 'xxx',
keyValue: 'xxx'
});
使用经过加密的 secretKey 播放
import 'xgplayer'
import Mp4Player from 'xgplayer-encrypt-mp4'
let player = new Mp4Player({
id: 'vs',
url: 'xxx',
secretKey: 'xxx',
withCredentials: true //支持请求携带cookie
});
通过传 drm 的方式播放
import 'xgplayer'
import Mp4Player from 'xgplayer-encrypt-mp4'
let player = new Mp4Player({
id: 'vs',
url: 'xxx',
vid: 'xxx',
drm: {
clearKeys: {
'xxx': 'xxx'
}
}
});
其它播放器配置参数和API使用请参考 http://h5player.bytedance.com/config/
兼容性
判断是否支持播放
Mp4Player.isSupported()
Android 4.4 以上 IOS 13 以上