Commit 2e90c7e7febce929820df65cc597fd08c2f1dc7b

Authored by 648540858
Committed by GitHub
2 parents a53fe776 35b3d761

Merge pull request #461 from hotcoffie/wvp-28181-2.0

修复多屏播放时播放器样式错位
web_src/src/components/common/jessibuca.vue
1 <template> 1 <template>
2 - <div id="container" ref="containerId" @dblclick="fullscreenSwich" style="background-color: #eee;margin:0 auto;"> 2 + <div ref="container" @dblclick="fullscreenSwich" style="background-color: #eee;margin:0 auto;">
3 <div class="buttons-box" id="buttonsBox"> 3 <div class="buttons-box" id="buttonsBox">
4 <div class="buttons-box-left"> 4 <div class="buttons-box-left">
5 <i v-if="!playing" class="iconfont icon-play jessibuca-btn" @click="playBtnClick"></i> 5 <i v-if="!playing" class="iconfont icon-play jessibuca-btn" @click="playBtnClick"></i>
@@ -71,7 +71,7 @@ export default { @@ -71,7 +71,7 @@ export default {
71 }, 71 },
72 methods: { 72 methods: {
73 updatePlayerDomSize() { 73 updatePlayerDomSize() {
74 - let dom = document.getElementById('container'); 74 + let dom = this.$refs.container;
75 let width = dom.parentNode.clientWidth 75 let width = dom.parentNode.clientWidth
76 let height = (9 / 16) * width 76 let height = (9 / 16) * width
77 const clientHeight = Math.min(document.body.clientHeight, document.documentElement.clientHeight) 77 const clientHeight = Math.min(document.body.clientHeight, document.documentElement.clientHeight)
@@ -85,12 +85,11 @@ export default { @@ -85,12 +85,11 @@ export default {
85 }, 85 },
86 create() { 86 create() {
87 let options = {}; 87 let options = {};
88 - console.log(this.$refs.containerId)  
89 console.log("hasAudio " + this.hasAudio) 88 console.log("hasAudio " + this.hasAudio)
90 89
91 this.jessibuca = new window.Jessibuca(Object.assign( 90 this.jessibuca = new window.Jessibuca(Object.assign(
92 { 91 {
93 - container: this.$refs.containerId, 92 + container: this.$refs.container,
94 videoBuffer: 0.2, // 最大缓冲时长,单位秒 93 videoBuffer: 0.2, // 最大缓冲时长,单位秒
95 isResize: true, 94 isResize: true,
96 decoder: "static/js/jessibuca/decoder.js", 95 decoder: "static/js/jessibuca/decoder.js",
@@ -247,7 +246,7 @@ export default { @@ -247,7 +246,7 @@ export default {
247 this.jessibuca.destroy(); 246 this.jessibuca.destroy();
248 } 247 }
249 if (document.getElementById("buttonsBox") == null) { 248 if (document.getElementById("buttonsBox") == null) {
250 - document.getElementById("container").appendChild(this.btnDom) 249 + this.$refs.container.appendChild(this.btnDom)
251 } 250 }
252 this.jessibuca = null; 251 this.jessibuca = null;
253 this.playing = false; 252 this.playing = false;
web_src/src/components/live.vue
@@ -15,8 +15,7 @@ @@ -15,8 +15,7 @@
15 <div style="width: 99%;height: 85vh;display: flex;flex-wrap: wrap;background-color: #000;"> 15 <div style="width: 99%;height: 85vh;display: flex;flex-wrap: wrap;background-color: #000;">
16 <div v-for="i in spilt" :key="i" class="play-box" 16 <div v-for="i in spilt" :key="i" class="play-box"
17 :style="liveStyle" :class="{redborder:playerIdx == (i-1)}" 17 :style="liveStyle" :class="{redborder:playerIdx == (i-1)}"
18 - @click="playerIdx = (i-1)"  
19 - > 18 + @click="playerIdx = (i-1)">
20 <div v-if="!videoUrl[i-1]" style="color: #ffffff;font-size: 30px;font-weight: bold;">{{ i }}</div> 19 <div v-if="!videoUrl[i-1]" style="color: #ffffff;font-size: 30px;font-weight: bold;">{{ i }}</div>
21 <player v-else :videoUrl="videoUrl[i-1]" fluent autoplay @screenshot="shot" @destroy="destroy"/> 20 <player v-else :videoUrl="videoUrl[i-1]" fluent autoplay @screenshot="shot" @destroy="destroy"/>
22 </div> 21 </div>
@@ -60,12 +59,13 @@ export default { @@ -60,12 +59,13 @@ export default {
60 59
61 computed: { 60 computed: {
62 liveStyle() { 61 liveStyle() {
63 - if (this.spilt == 1) {  
64 - return {width: '100%', height: '100%'}  
65 - } else if (this.spilt == 4) {  
66 - return {width: '49%', height: '49%'}  
67 - } else if (this.spilt == 9) {  
68 - return {width: '32%', height: '32%'} 62 + switch (this.spilt) {
  63 + case 4:
  64 + return {width: '49%', height: '49%'}
  65 + case 9:
  66 + return {width: '32%', height: '32%'}
  67 + default:
  68 + return {width: '100%', height: '100%'}
69 } 69 }
70 } 70 }
71 }, 71 },