|
@@ -28,8 +28,8 @@
|
|
|
</view>
|
|
|
<view class="videoBox" v-if="videoList">
|
|
|
<view class="title">演示视频</view>
|
|
|
- <view class="video" v-for="video in videoList" :key="video.id">
|
|
|
- <video :src="playerURL(video.url)" controls :title="video.name" :type="video.type"></video>
|
|
|
+ <view class="video" v-for="(video, index) in videoList" :key="video.id">
|
|
|
+ <video :src="playerURL(video.url)" controls :id="video.id" :data-id="video.id" :title="video.name" @play="videoPlay" :type="video.type"></video>
|
|
|
<view class="info">{{video.name}}</view>
|
|
|
</view>
|
|
|
</view>
|
|
@@ -61,6 +61,20 @@
|
|
|
},
|
|
|
playerURL(url) {
|
|
|
return playerVideo(url)
|
|
|
+ },
|
|
|
+ videoPlay(e) {
|
|
|
+ // 获取当前视频id
|
|
|
+ let currentId = e.currentTarget.dataset.id;
|
|
|
+ // uni.createVideoContext获取视频上下文对象
|
|
|
+ this.videoContent = uni.createVideoContext(currentId);
|
|
|
+ // 获取json对象并遍历, 停止非当前视频
|
|
|
+ let videoList = this.videoList;
|
|
|
+ for (let i = 0; i < videoList.length; i++) {
|
|
|
+ let temp = videoList[i].id;
|
|
|
+ if (temp !== currentId) {
|
|
|
+ uni.createVideoContext(temp).pause();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
onLoad(option) {
|