Dplayer 官方文檔地址
Dplayer官方地址
雖然在vue中有vue-dplayer但卻沒有對hls進(jìn)行很好的支持 所以建議還是使用Dplayer
npm i dplayer
npm i hls.js
在組件中引入
播放m3u8格式的視頻需要框選部分 – 建議查看官方文檔MSE支持文章來源:http://www.zghlxwxcb.cn/news/detail-644440.html
切換視頻
切換視頻需要用到switchVideo()
api文章來源地址http://www.zghlxwxcb.cn/news/detail-644440.html
方便大家復(fù)制 部分片段
this.Dp = new Dplayer({
element:this.$refs.player,
mutex:false,
loop:true,
lang:'zh-cn',
autoplay:true,
preload:'none',
video:{
url:'',
type: 'customHls',
customType: {
customHls: function (video, player) {
console.log('video',video,player);
const hls = new HLS();
hls.loadSource(video.src);
hls.attachMedia(video);
},
},
}
})
到了這里,關(guān)于在vue中使用dplayer播放hls m3u8格式視頻的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!