初学者123
初学者123
  • 发布:2020-06-07 06:14
  • 更新:2020-06-07 06:14
  • 阅读:965

APP端点击视频播放,同一页面的几个视频同时播放

分类:uni-app

<template>  
<view class="record-img" v-if="item.is_video == '1' ">  
<video id="myVideo" :src="item.file_url" :poster="item.imageurl" @tap="play_video" @ended="exit_fullscreen" enable-play-gesture controls></video>  
</view>  
</template>  

<script>  
export default{  
    data:{  
        return {  
            video_isPlay: false,  
        video_isFullscreen: false,  
}  
},  

onReady: function(res) {  
    this.videoContext = uni.createVideoContext('myVideo');  
},  
methods: {  
      play_video(e) {  
                console.log(this.video_isPlay,this.video_isFullscreen)  
                if(this.video_isPlay == false && this.video_isFullscreen == false){  
                    this.videoContext.play();  
                    this.videoContext.requestFullScreen(0);  
                    this.video_isPlay = true;  
                    this.video_isFullscreen = true;  
                }else if(this.video_isPlay == true && this.video_isFullscreen == true){  
                    this.videoContext.exitFullScreen();  
                    this.videoContext.pause();  
                    this.video_isPlay = false;  
                    this.video_isFullscreen = false;  
                }else if(this.video_isPlay == false && this.video_isFullscreen == true){  
                    this.videoContext.exitFullScreen();  
                    this.video_isFullscreen = false;  
                    this.video_isPlay = false;  
                }  
                console.log(e,this.video_isPlay,this.video_isFullscreen)  
            },  

}

分析:考虑为加载时,同一页面video标签内,id为"myVideo"的所有视频一同被加载。文档中没有给出如何传递当前视频id值的方法。请帮忙,谢谢!
}

2020-06-07 06:14 负责人:无 分享
已邀请:

该问题目前已经被锁定, 无法添加新回复