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

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

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

posted @ 2021-09-10 16:30  菜鸟小何  阅读(1641)  评论(0编辑  收藏  举报