我們先看一下官方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。
坑 坑 坑,文檔上根本沒有這個屬性
