西瓜播放器api的坑 直播设置自动播放

2023-05-03,,

我们先看一下官方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。

坑 坑 坑,文档上根本没有这个属性

西瓜播放器api的坑 直播设置自动播放的相关教程结束。

《西瓜播放器api的坑 直播设置自动播放.doc》

下载本文的Word格式文档,以方便收藏与打印。