全頁代碼可直接貼上,另外請建立兩條10秒鐘左右的短mp4,位置及名稱如下:
"/storage/emulated/0/your_App/1-1-1/gg.mp4",
"/storage/emulated/0/your_App/1-1-1/ff.mp4",
然後getMedia()分別各自return 以下內容
return this.playingDict[key]['src'][this.playingDict[key]['counter']] //含計算步驟<<<<<<<<<<<
及
return "/storage/emulated/0/your_App/1-1-1/gg.mp4" //不含計算步驟 <<<<<<<<<<<
含計算步驟 會在打印'end'後打印'print me'
不含計算步驟 只會在打印一開頭打印'print me'
<template>
<view>
<view v-for="(myObject,key,myIndex) in playingDict">
<video class="myVideo" :src="getMedia(key)" @ended="playEnd(key)" show-loading=false controls=false autoplay
loop :style='
"left:"+0+"px;"+
"top:"+0+"px;"+
"width:"+640+"px;"+
"height:"+360+"px;"
'></video>
</view>
</view>
</template>
<script>
export default {
data() {
return {
staticPath: "/storage/emulated/0/your_App/",
playingDict: {
"AA":{
"src":[
"/storage/emulated/0/your_App/1-1-1/gg.mp4",
"/storage/emulated/0/your_App/1-1-1/ff.mp4"],
"counter":0,
'left':0,
'top':0,
'width':640,
'height':360
},
},
}
},
onLoad() {
console.log('onLoad')
},
onReady() {},
methods: {
getMedia(key){
console.log('print me')
return this.playingDict[key]['src'][this.playingDict[key]['counter']] //含計算步驟<<<<<<<<<<<
// return "/storage/emulated/0/your_App/1-1-1/gg.mp4" //不含計算步驟 <<<<<<<<<<<
},
playEnd(key){
this.playingDict[key]['counter'] += 1
console.log('end')
}
},
watch: {}
}
</script>
<style>
.myVideo {
position: absolute;
}
</style>
2 个回复
samshum22 (作者)
也不是100%有計算步驟 就會執行 :
這才是最終代碼,本來想return 下一部mp4,結果只return 第一次
所以做不了輪播效果
救命...
samshum22 (作者)
請開發人員確認bug後,回覆一下,
以及會否有人跟進?
好向老闆交代
bug修復後本人也會捐出100元,以作感謝uniapp工作人員的貢獻