我们先看一下官方DEMO
let player = new HlsPlayer({
id: 'mse',
url: '//sf1-cdn-tos.huoshanstatic.com/obj/media-fe/xgplayer\_doc\_video/hls/xgplayer-demo.m3u8',
isLive: true,
autoplay: true,
playsinline: true,
height: window.innerHeight,
width: window.innerWidth
});
官方教程是让我们通过autoplay: true设置自动播放 所以我代码是这么写的
this.player = new HlsJsPlayer({
id: `mse`,
url: '//sf1-cdn-tos.huoshanstatic.com/obj/media-fe/xgplayer_doc_video/hls/xgplayer-demo.m3u8',
isLive: true,
autoplay: true,
playsinline: true,
height: window.innerHeight,
width: window.innerWidth
});
神奇的事情发生了,这个自动播放属性再vue中未生效 ,需要手动点击播放按钮播放。于是我百度 也有别人遇到了这个问题,并提供了解决方案。
加一个属性 autoplayMuted: true。
坑 坑 坑,文档上根本没有这个属性
手机扫一扫
移动阅读更方便
你可能感兴趣的文章