西瓜播放器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。

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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM