Commit 98817b0e authored by jyx's avatar jyx

优化自动播放

parent 9af139b6
......@@ -127,7 +127,7 @@
}
},
stop() {
audo.pause()
// audo.pause()
this.videoContext?.pause()
},
queryList() {
......
......@@ -4,10 +4,10 @@
<swiper class="swiper" circular @change="swiperChange" :current="current" :vertical="true">
<swiper-item v-for="(list, index) in displaySwiperList" :key="index" :style="'width:100%; height:100%;'">
<view :style="'width:100%; height:100%;'">
<video v-if="Math.abs(displayIndex-index)==0 && list.vedioUrl" :id="list.vedioId"
<video v-if="Math.abs(displayIndex-index)==0 && list.vedioUrl" :id="list.vedioIndex"
:controls="controls" :loop="!isplay" :enable-progress-gesture="false" :show-loading="true"
:show-fullscreen-btn="false" @ended="ended" @controlstoggle="controlstoggle" @click="tapVides()"
@timeupdate="timeupdate" style="width:100%; height:100%;background: #f56c6c;"
@timeupdate="timeupdate" style="width:100%; height:100%;background: #f56c6c;" :autoplay="true"
:src="list.vedioUrl" :poster="data.coverImage" class="tsvideo" play-btn-position="center"
object-fit="contain" />
<view v-if="!isqp" class="userInfo">
......@@ -132,7 +132,6 @@
ref
} from "vue";
let audo = uni.createInnerAudioContext()
export default {
name: "newVideoDetail",
mixins: [common],
......@@ -193,12 +192,10 @@
onShow() {
// 从VIP页面返回关闭弹框
this.down()
// this.getData()
},
methods: {
paySuccess() {
this.unlock(this.originIndex)
// this.getData()
},
showPayDialog() {
let isIOS = wx.getSystemInfoSync().platform;
......@@ -222,13 +219,18 @@
timeupdate(event) {
// 自动播放下一集
if (event.detail.currentTime > 0 && this.originList[this.originIndex].lock) {
uni.createVideoContext('' + this.originList[this.originIndex].vedioId, this).seek(0);
uni.createVideoContext('' + this.originList[this.originIndex].vedioId, this).pause();
uni.createVideoContext('' + this.originList[this.originIndex].vedioIndex, this).seek(0);
uni.createVideoContext('' + this.originList[this.originIndex].vedioIndex, this).pause();
this.unlock(this.originIndex)
}
},
selectThisVideo(index) {
this.down();
if (this.originIndex == index) {
return
}
this.oid = this.originIndex
this.duration = 20;
this.originIndex = index
this.initSwiperData(this.originIndex);
......@@ -276,26 +278,29 @@
if (data.code == 200) {
that.originList[that.originIndex].lock = false
setTimeout(() => {
uni.createVideoContext('' + that.originList[that.originIndex].vedioId,
uni.createVideoContext('' + that.originList[that.originIndex]
.vedioIndex,
that)
.play();
this.commitVideo()
that.commitVideo()
}, 500)
} else if (data.code == 301) {
that.originList[that.originIndex].lock = false
setTimeout(() => {
uni.createVideoContext('' + that.originList[that.originIndex].vedioId,
uni.createVideoContext('' + that.originList[that.originIndex]
.vedioIndex,
that)
.play();
this.commitVideo()
that.commitVideo()
}, 500)
} else if (data.code == 302) {
that.originList[that.originIndex].lock = false
setTimeout(() => {
uni.createVideoContext('' + that.originList[that.originIndex].vedioId,
uni.createVideoContext('' + that.originList[that.originIndex]
.vedioIndex,
that)
.play();
this.commitVideo()
that.commitVideo()
}, 500)
} else if (data.code == 303) {
that.showPayDialog()
......@@ -304,6 +309,7 @@
});
},
getData() {
let that = this
this.originList = []
this.post({
url: '/vedio/getIndexList',
......@@ -314,18 +320,18 @@
success: ({
data
}) => {
this.originList = data.list
if (this.isPlayNext == 1) {
this.originIndex = this.data.recommendIndex - 1
that.originList = data.list
if (that.isPlayNext == 1) {
that.originIndex = that.data.recommendIndex - 1
} else {
this.originIndex = this.data.seeIndex - 1
that.originIndex = that.data.seeIndex - 1
}
if (this.originIndex >= this.data.vedioTotal || this.originIndex < 0) {
this.originIndex = 0
if (that.originIndex >= that.data.vedioTotal || that.originIndex < 0) {
that.originIndex = 0
}
this.data = data.vedioMsg
this.initSwiperData(this.originIndex);
this.initEpisode()
that.data = data.vedioMsg
that.initSwiperData(that.originIndex);
that.initEpisode()
}
});
},
......@@ -359,8 +365,6 @@
];
this.displaySwiperList = displayList;
// audo.pause()
if (this.oid >= this.originList.length) {
this.oid = 0
}
......@@ -368,15 +372,14 @@
this.oid = this.originList.length - 1
}
console.log('++++++++++++上一条播放数据 Index:', this.oid)
// uni.createVideoContext('' + this.originList[this.oid].vedioId, this).stop();
uni.createVideoContext('' + this.originList[this.oid].vedioId, this).pause();
uni.createVideoContext('' + this.originList[this.oid].vedioIndex, this).pause();
if (this.originList[originIndex].lock) {
this.unlock(this.originIndex)
} else {
setTimeout(() => {
// audo.play()
uni.createVideoContext('' + this.originList[originIndex].vedioId, this).play();
uni.createVideoContext('' + this.originList[originIndex].vedioIndex, this).play();
this.commitVideo()
}, 500)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment