-
+
-
@@ -41,36 +41,67 @@
},
onLoad(op) {
this.currentIndex = op.current;
- this.videoList = uni.getStorageSync('videoList');
+ uni.getStorageSync('videoList').forEach(item=>{
+ let obj = {
+ ...item,
+ isPlayImg:true,
+ autoplay:false,
+ isControls:false
+ }
+ this.videoList.push(obj);
+ })
+ this.videoList[this.currentIndex].autoplay = true;
this.videoContext = uni.createVideoContext(`video${this.currentIndex}`, this)
},
+ onHide() {
+ uni.removeStorageSync('videoList');
+ },
methods:{
+ // 视频滑动结束
+ getxy(e){
+ let num = e.detail.dy;
+ if(num==this.newHeight || -num==this.newHeight){
+ this.playCurrentVideo(this.currentIndex);
+ }
+ },
+ // 滑动swiper 设置当前视频索引
+ switchVideo(e){
+ this.currentIndex = e.detail.current;
+ },
// 双击
doubleClick(index){
this.count++;
setTimeout(()=>{
- if(this.count>2 && this.videoList[index].isPlayImg == true){
- this.playCurrentVideo(index);
- this.count = 0;
- } else {
+ this.count = 0;
+ },300)
+ if(this.count>2){
+ if(this.videoList[index].isPlayImg){
+ // 如果当前视频正在播放中,双击及暂停播放
+ this.videoContext.pause();
this.videoList[index].isPlayImg = true;
+ } else {
+ // 如果当前视频暂停中,双击及开始播放
+ this.videoList[index].isPlayImg = false;
+ this.videoContext.play();
}
- },1000)
+ }
},
// 播放当前视频
playCurrentVideo(index){
this.videoContext.pause();
- this.videoContext = uni.createVideoContext(`video${index}`, this)
+ this.videoContext = uni.createVideoContext(`video${index}`, this);
this.videoList[index].isPlayImg = false;
+ this.videoContext.play();
},
+ // 退出视频播放
backEv(){
uni.navigateBack({
delta:1
})
},
+ // 点击播放图标,播放视频
playEv(index){
this.playCurrentVideo(index);
- this.videoContext.play();
},
// 视频播放
comePlay(index){//当开始/继续播放时触发play事件