Commit 1a73a63a06054205ab946c4fa68b8f65e2301505

Authored by fengtao
1 parent dc86fc85

fix:DEFECT-389 修改摄像头能同时播放多个问题

Showing 1 changed file with 37 additions and 11 deletions
@@ -17,16 +17,24 @@ @@ -17,16 +17,24 @@
17 <mescroll-body ref="mescrollRef" :up="upOption" @init="mescrollInit" :down="downOption" @down="downCallback" @up="upCallback"> 17 <mescroll-body ref="mescrollRef" :up="upOption" @init="mescrollInit" :down="downOption" @down="downCallback" @up="upCallback">
18 <view class="camera-container"> 18 <view class="camera-container">
19 <view class="container-item"> 19 <view class="container-item">
20 - <view @click="openCameraDetail(item.url)" v-for="(item, index) in list" :key="index" class="item">  
21 - <video class="video" :src="item.videoUrl" controls></video> 20 + <view v-for="(item, index) in list" :key="index" class="item">
  21 + <video
  22 + :data-id="item.id"
  23 + :key="item.id"
  24 + :id="'video' + item.id"
  25 + class="video"
  26 + :src="item.videoUrl"
  27 + controls
  28 + webkit-playsinline
  29 + x5-video-player-type="h5"
  30 + x5-video-orientation="portraint"
  31 + show-mute-btn
  32 + :poster="item.avatar"
  33 + @play="playVideo"
  34 + ></video>
22 <view class="bottom-text"> 35 <view class="bottom-text">
23 <text class="text">{{ item.name }}</text> 36 <text class="text">{{ item.name }}</text>
24 </view> 37 </view>
25 - <!-- #ifdef MP -->  
26 - <view @click="hideImageUrl(item, index)" :style="[index == current ? { display: 'none' } : { display: 'block' }]" class="avatar-cover">  
27 - <image class="image" :src="item.avatar"></image>  
28 - </view>  
29 - <!-- #endif -->  
30 </view> 38 </view>
31 </view> 39 </view>
32 </view> 40 </view>
@@ -56,7 +64,8 @@ export default { @@ -56,7 +64,8 @@ export default {
56 current: 0, 64 current: 0,
57 cameraTotal: 0, 65 cameraTotal: 0,
58 list: [], 66 list: [],
59 - ordId: '' 67 + ordId: '',
  68 + videoContext: null
60 }; 69 };
61 }, 70 },
62 onShow() { 71 onShow() {
@@ -65,6 +74,9 @@ export default { @@ -65,6 +74,9 @@ export default {
65 this.loadData(1, this.ordId); 74 this.loadData(1, this.ordId);
66 } 75 }
67 }, 76 },
  77 + onReady() {
  78 + this.videoContext = uni.createVideoContext('myVideo', this);
  79 + },
68 onHide() { 80 onHide() {
69 this.ordId = ''; 81 this.ordId = '';
70 this.loadData(1, null); 82 this.loadData(1, null);
@@ -72,7 +84,6 @@ export default { @@ -72,7 +84,6 @@ export default {
72 onLoad() { 84 onLoad() {
73 // 隐藏原生的tabbar 85 // 隐藏原生的tabbar
74 uni.hideTabBar(); 86 uni.hideTabBar();
75 - this.getcameraTotalData();  
76 }, 87 },
77 methods: { 88 methods: {
78 /*下拉刷新的回调 */ 89 /*下拉刷新的回调 */
@@ -113,8 +124,23 @@ export default { @@ -113,8 +124,23 @@ export default {
113 hideImageUrl(item, index) { 124 hideImageUrl(item, index) {
114 this.current = index; 125 this.current = index;
115 }, 126 },
116 - openCameraDetail(e) {  
117 - console.log(e); 127 + playVideo(e) {
  128 + /**
  129 + * 播放当前视频,暂停其余视频
  130 + */
  131 + let currentId = 'video' + e.currentTarget.dataset.id;
  132 + this.videoContent = uni.createVideoContext(currentId, this);
  133 + this.videoContext.requestFullScreen({ direction: 90 });
  134 + // 获取视频列表
  135 + let trailer = this.list;
  136 + trailer.forEach((item, index) => {
  137 + if (item.videoUrl != null && item.videoUrl != '') {
  138 + let temp = 'video' + item.id;
  139 + if (temp != currentId) {
  140 + uni.createVideoContext(temp, this).pause();
  141 + }
  142 + }
  143 + });
118 }, 144 },
119 openOrg() { 145 openOrg() {
120 uni.navigateTo({ 146 uni.navigateTo({