浏览代码

视频全屏播放结束bug

jwyu 2 年之前
父节点
当前提交
ac1620638e
共有 1 个文件被更改,包括 14 次插入1 次删除
  1. 14 1
      pages/video/videoList.vue

+ 14 - 1
pages/video/videoList.vue

@@ -42,7 +42,7 @@
                     :src="item.video_url"
                     enable-play-gesture
                     :id="item.community_video_id"
-                    @ended="curVideoId=0"
+                    @ended="handleVideoEnd"
                     v-if="item.community_video_id==curVideoId"
                 ></video>
                 <image @click="handelClickPlay(item)" v-else class="poster" :src="item.cover_img_url" mode="aspectFill" lazy-load/>
@@ -111,6 +111,7 @@ export default {
             list:[],
 
             curVideoId:0,
+            curVideoIns:null
         }
     },
     onLoad(options){
@@ -220,12 +221,24 @@ export default {
 
         handelClickPlay(item){
             this.curVideoId=item.community_video_id
+            setTimeout(() => {
+                this.curVideoIns=uni.createVideoContext(this.curVideoId.toString())
+            }, 300);
             // 记录播放
             apiVideoPlayLog({video_id:Number(item.community_video_id)}).then(res=>{
                 if(res.code===200){
                     console.log('视频埋点成功');
                 }
             })
+        },
+
+        //视频播放结束
+        handleVideoEnd(){
+            this.curVideoIns.exitFullScreen()
+            setTimeout(() => {
+                this.curVideoId=0
+                this.curVideoIns=null
+            }, 200);
         }
     },
 }