Commit 3eef73ecb6e8fa36466cd8921a6129c886911138
1 parent
c3b47fa7
修复实时监控无法播放问题 #427
Showing
3 changed files
with
45 additions
and
28 deletions
web_src/src/components/dialog/devicePlayer.vue
| ... | ... | @@ -3,7 +3,9 @@ |
| 3 | 3 | |
| 4 | 4 | <el-dialog title="视频播放" top="0" :close-on-click-modal="false" :visible.sync="showVideoDialog" @close="close()"> |
| 5 | 5 | <!-- <LivePlayer v-if="showVideoDialog" ref="videoPlayer" :videoUrl="videoUrl" :error="videoError" :message="videoError" :hasaudio="hasaudio" fluent autoplay live></LivePlayer> --> |
| 6 | - <player ref="videoPlayer" :visible.sync="showVideoDialog" :videoUrl="videoUrl" :error="videoError" :message="videoError" :height="false" :hasAudio="hasAudio" fluent autoplay live ></player> | |
| 6 | + <div style="width: 100%; height: 100%"> | |
| 7 | + <player containerId="container" ref="videoPlayer" :visible.sync="showVideoDialog" :videoUrl="videoUrl" :error="videoError" :message="videoError" height="100px" :hasAudio="hasAudio" fluent autoplay live ></player> | |
| 8 | + </div> | |
| 7 | 9 | <div id="shared" style="text-align: right; margin-top: 1rem;"> |
| 8 | 10 | <el-tabs v-model="tabActiveName" @tab-click="tabHandleClick"> |
| 9 | 11 | <el-tab-pane label="实时视频" name="media"> | ... | ... |
web_src/src/components/dialog/jessibuca.vue
| 1 | 1 | <template> |
| 2 | - <div id="jessibuca" style="width: auto; height: auto"> | |
| 3 | - <div id="container" ref="container" style="width: 100%; height: 10rem; background-color: #000" @dblclick="fullscreenSwich"> | |
| 4 | - <div class="buttons-box" id="buttonsBox"> | |
| 5 | - <div class="buttons-box-left"> | |
| 6 | - <i v-if="!playing" class="iconfont icon-play jessibuca-btn" @click="playBtnClick"></i> | |
| 7 | - <i v-if="playing" class="iconfont icon-pause jessibuca-btn" @click="pause"></i> | |
| 8 | - <i class="iconfont icon-stop jessibuca-btn" @click="destroy"></i> | |
| 9 | - <i v-if="isNotMute" class="iconfont icon-audio-high jessibuca-btn" @click="jessibuca.mute()"></i> | |
| 10 | - <i v-if="!isNotMute" class="iconfont icon-audio-mute jessibuca-btn" @click="jessibuca.cancelMute()"></i> | |
| 11 | - </div> | |
| 12 | - <div class="buttons-box-right"> | |
| 13 | - <span class="jessibuca-btn">{{kBps}} kb/s</span> | |
| 14 | -<!-- <i class="iconfont icon-file-record1 jessibuca-btn"></i>--> | |
| 15 | -<!-- <i class="iconfont icon-xiangqing2 jessibuca-btn" ></i>--> | |
| 16 | - <i class="iconfont icon-camera1196054easyiconnet jessibuca-btn" @click="jessibuca.screenshot('截图','png',0.5)" style="font-size: 1rem !important"></i> | |
| 17 | - <i class="iconfont icon-shuaxin11 jessibuca-btn" @click="playBtnClick"></i> | |
| 18 | - <i v-if="!fullscreen" class="iconfont icon-weibiaoti10 jessibuca-btn" @click="fullscreenSwich"></i> | |
| 19 | - <i v-if="fullscreen" class="iconfont icon-weibiaoti11 jessibuca-btn" @click="fullscreenSwich"></i> | |
| 20 | - </div> | |
| 21 | - </div> | |
| 22 | - | |
| 2 | + <div :id="containerId" :ref="containerId" style="width: 100%;height: auto; background-color: #000" @dblclick="fullscreenSwich"> | |
| 3 | + <div class="buttons-box" id="buttonsBox"> | |
| 4 | + <div class="buttons-box-left"> | |
| 5 | + <i v-if="!playing" class="iconfont icon-play jessibuca-btn" @click="playBtnClick"></i> | |
| 6 | + <i v-if="playing" class="iconfont icon-pause jessibuca-btn" @click="pause"></i> | |
| 7 | + <i class="iconfont icon-stop jessibuca-btn" @click="destroy"></i> | |
| 8 | + <i v-if="isNotMute" class="iconfont icon-audio-high jessibuca-btn" @click="jessibuca.mute()"></i> | |
| 9 | + <i v-if="!isNotMute" class="iconfont icon-audio-mute jessibuca-btn" @click="jessibuca.cancelMute()"></i> | |
| 10 | + </div> | |
| 11 | + <div class="buttons-box-right"> | |
| 12 | + <span class="jessibuca-btn">{{kBps}} kb/s</span> | |
| 13 | + <!-- <i class="iconfont icon-file-record1 jessibuca-btn"></i>--> | |
| 14 | + <!-- <i class="iconfont icon-xiangqing2 jessibuca-btn" ></i>--> | |
| 15 | + <i class="iconfont icon-camera1196054easyiconnet jessibuca-btn" @click="jessibuca.screenshot('截图','png',0.5)" style="font-size: 1rem !important"></i> | |
| 16 | + <i class="iconfont icon-shuaxin11 jessibuca-btn" @click="playBtnClick"></i> | |
| 17 | + <i v-if="!fullscreen" class="iconfont icon-weibiaoti10 jessibuca-btn" @click="fullscreenSwich"></i> | |
| 18 | + <i v-if="fullscreen" class="iconfont icon-weibiaoti11 jessibuca-btn" @click="fullscreenSwich"></i> | |
| 19 | + </div> | |
| 23 | 20 | </div> |
| 24 | 21 | </div> |
| 25 | 22 | </template> |
| ... | ... | @@ -46,15 +43,20 @@ export default { |
| 46 | 43 | forceNoOffscreen: false, |
| 47 | 44 | }; |
| 48 | 45 | }, |
| 49 | - props: ['videoUrl', 'error', 'hasAudio', 'height'], | |
| 46 | + props: ['containerId','videoUrl', 'error', 'hasAudio', 'height'], | |
| 50 | 47 | mounted () { |
| 51 | 48 | window.onerror = (msg) => { |
| 52 | 49 | // console.error(msg) |
| 53 | 50 | }; |
| 54 | 51 | let paramUrl = decodeURIComponent(this.$route.params.url) |
| 55 | 52 | this.$nextTick(() =>{ |
| 56 | - let dom = document.getElementById("container"); | |
| 57 | - dom.style.height = (9/16 ) * dom.clientWidth + "px" | |
| 53 | + let dom = document.getElementById(this.containerId); | |
| 54 | + if (dom.parentNode.clientHeight == 0) { | |
| 55 | + dom.style.height = (9/16 ) * dom.clientWidth + "px" | |
| 56 | + } | |
| 57 | + dom.style.height = dom.parentNode.clientHeight + "px"; | |
| 58 | + dom.style.width = dom.parentNode.clientWidth + "px"; | |
| 59 | + | |
| 58 | 60 | if (typeof (this.videoUrl) == "undefined") { |
| 59 | 61 | this.videoUrl = paramUrl; |
| 60 | 62 | } |
| ... | ... | @@ -72,12 +74,12 @@ export default { |
| 72 | 74 | methods: { |
| 73 | 75 | create(){ |
| 74 | 76 | let options = {}; |
| 75 | - console.log(this.$refs.container) | |
| 77 | + console.log(this.$refs[this.containerId]) | |
| 76 | 78 | console.log("hasAudio " + this.hasAudio) |
| 77 | 79 | |
| 78 | 80 | this.jessibuca = new window.Jessibuca(Object.assign( |
| 79 | 81 | { |
| 80 | - container: this.$refs.container, | |
| 82 | + container: this.$refs[this.containerId], | |
| 81 | 83 | videoBuffer: 0.2, // 最大缓冲时长,单位秒 |
| 82 | 84 | isResize: true, |
| 83 | 85 | decoder:"static/js/jessibuca/decoder.js", |
| ... | ... | @@ -198,6 +200,19 @@ export default { |
| 198 | 200 | |
| 199 | 201 | }); |
| 200 | 202 | }, |
| 203 | + resize(){ | |
| 204 | + if (this.jessibuca){ | |
| 205 | + this.jessibuca.resize() | |
| 206 | + this.$nextTick(() =>{ | |
| 207 | + let dom = document.getElementById(this.containerId); | |
| 208 | + if (dom.parentNode.clientHeight == 0) { | |
| 209 | + dom.style.height = (9/16 ) * dom.clientWidth + "px" | |
| 210 | + } | |
| 211 | + dom.style.height = dom.parentNode.clientHeight + "px"; | |
| 212 | + dom.style.width = dom.parentNode.clientWidth + "px"; | |
| 213 | + }) | |
| 214 | + } | |
| 215 | + }, | |
| 201 | 216 | playBtnClick: function (event){ |
| 202 | 217 | this.play(this.videoUrl) |
| 203 | 218 | }, | ... | ... |
web_src/src/components/live.vue
| ... | ... | @@ -33,7 +33,7 @@ |
| 33 | 33 | > |
| 34 | 34 | <div v-if="!videoUrl[i-1]" style="color: #ffffff;font-size: 30px;font-weight: bold;">{{i}}</div> |
| 35 | 35 | <player v-else :ref="'player'+i" :videoUrl="videoUrl[i-1]" fluent autoplay :height="true" |
| 36 | - :idx="'player'+i" @screenshot="shot" @destroy="destroy"></player> | |
| 36 | + :containerId="'player'+i" @screenshot="shot" @destroy="destroy"></player> | |
| 37 | 37 | <!-- <player v-else ref="'player'+i" :idx="'player'+i" :visible.sync="showVideoDialog" :videoUrl="videoUrl[i-1]" :height="true" :hasAudio="hasAudio" fluent autoplay live ></player> --> |
| 38 | 38 | </div> |
| 39 | 39 | </div> | ... | ... |