Browse Source

VideoPlayer 自动播放设置

reghao 2 năm trước cách đây
mục cha
commit
ec9b499f32
1 tập tin đã thay đổi với 4 bổ sung3 xóa
  1. 4 3
      src/components/VideoPlayer.vue

+ 4 - 3
src/components/VideoPlayer.vue

@@ -48,7 +48,8 @@ export default {
             for (const url of urls) {
               url.type = 'normal'
             }
-            this.initMp4Player(this.videoProp.userId, videoId, this.videoProp.coverUrl, urls, res.data.currentTime)
+            const autoPlay = false
+            this.initMp4Player(this.videoProp.userId, videoId, this.videoProp.coverUrl, urls, res.data.currentTime, autoPlay)
           } else if (urlType === 'flv') {
             const urls = res.data.urls
             const url = urls[0].url
@@ -78,13 +79,13 @@ export default {
     danmakuConfig() {
       // TODO 获取弹幕配置,将 videoUrl 作为本函数的回调
     },
-    initMp4Player(userId, videoId, coverUrl, urls, pos) {
+    initMp4Player(userId, videoId, coverUrl, urls, pos, autoPlay) {
       const player = new DPlayer({
         container: document.querySelector('#dplayer'),
         lang: 'zh-cn',
         logo: '/logo.png',
         screenshot: false,
-        autoplay: true,
+        autoplay: autoPlay,
         volume: 0.1,
         mutex: true,
         video: {