视频格式,采用了hls视频加密(视频地址后缀是.m3u8)
xgplayer默认也是不支持m3u8视频的,xgplayer-hls,代码如下:
import HlsPlugin from 'xgplayer-hls';
import 'xgplayer/dist/index.min.css';
export default {
mounted() {
this.player = new Player({
width: '100%',
height: '100%',
id: `player-container`,
url: url,
isLive: false,
plugins: [HlsPlugin]
})
}
}
报错信息 crypto is not defined
播放加密流需要在https环境才能支持,并且 crypto 也只在HTTPS环境内才有这个对象
本地localhost和HTTPS都可以访问crypto对象。但通过正常的IP或域名再配合http访问却不支持crypto,所以项目环境想要使用解密对象crypto需要部署在https域名下
xgplayer-hls用到了浏览器的cryptoAPI,这个api使用是有限制的,仅在域名为localhost或者https的域名下才能生效