Commit 98817b0e authored by jyx's avatar jyx

优化自动播放

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