<template>
<view class="content">
<text>TEST</text>
<button @click="back">null</button>
<button @click="back">back</button>
<view v-if="waited">
<view v-for="(myObject,key,myIndex) in playingDict">
<text>| myObject:{{myObject}} | key:{{key}} | myIndex:{{myIndex}}</text>
<text>{{Object.keys(myObject)}}{{Object.values(myObject)}}</text>
<video class="myVideo" :src="getMedia(key)" @ended="playEnd(key)" show-loading=false controls=false
autoplay loop :style='
"left:"+myObject.left+"px;"+
"top:"+myObject.top+"px;"+
"width:"+myObject.width+"px;"+
"height:"+myObject.height+"px;"
'></video>
</view>
</view>
<view>
{{waited}}
</view>
</view>
</template>
<script>
export default {
data() {
return {
screen: 1,
staticPath: "/storage/emulated/0/your_app/1-",
playingDict: {
"A":{
"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,
},
"B":{
"src":[
"/storage/emulated/0/your_app/1-1-1/ff.mp4",
"/storage/emulated/0/your_app/1-1-1/gg.mp4"],
"counter":0,
'left':0,
'top':360,
'width':640,
'height':360,
}
},
machineInfo: {},
waited: true
}
},
onLoad() {
},
onReady() {
},
methods: {
getMedia(obj){
let index = this.playingDict[obj]['counter'] % this.playingDict[obj]['src'].length
console.log('getMedia')
return this.playingDict[obj]['src'][index]
},
playEnd(obj){
this.playingDict[obj]['counter'] += 1
},
back() {
uni.redirectTo({
url: '../index/index'
});
},
},
4 个回复
DCloud_uniCloud_JSON
也许参考这两个插件你可以获得帮助:https://ext.dcloud.net.cn/plugin?id=860 , https://ext.dcloud.net.cn/plugin?id=3549
samshum22
...唉,難搞,不知道背後出了什麼問題,我寫了兩個程序,兩個都是在playend的時候改counter然後 :src = getMediaFun() 取回相應的值.
但一個可用,一個不可用,兩個都是差不多的結構
samshum22
2***@qq.com
先用一个空的view替代vedio的位置,然后获取到vedio的src后再用空的view隐藏,vedio标签显示