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