<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值的方法。请帮忙,谢谢!
}
0 个回复