Explorar el Código

处理音视频声音问题

leo hace 9 meses
padre
commit
b2ee2ce674
Se han modificado 2 ficheros con 14 adiciones y 25 borrados
  1. 2 2
      static/rtcEngine/WXtrialInterface.html
  2. 12 23
      static/rtcEngine/js/WXtrialInterface.js

+ 2 - 2
static/rtcEngine/WXtrialInterface.html

@@ -60,10 +60,10 @@
                             <div class="tc drawer-item mb-15" @click.prevent="resolutionRatio">
                                 分辨率
                             </div>
-                            <div class="tc drawer-item mb-15" @click.prevent="engine.ExexuteKeyBoard(24)">
+                            <div class="tc drawer-item mb-15" @click.prevent="volumeControl(24)">
                                 音量 +
                             </div>
-                            <div class="tc drawer-item" @click.prevent="engine.ExexuteKeyBoard(25)">
+                            <div class="tc drawer-item" @click.prevent="volumeControl(25)">
                                 音量 -
                             </div>
                         </div>

+ 12 - 23
static/rtcEngine/js/WXtrialInterface.js

@@ -241,25 +241,8 @@ const app = new Vue({
                         Toast.clear();
                         this.doConnectDirectives()
                         this.isShowVideo = true
-                        this.$refs.rtcMediaPlayer.volume = 0
-                        console.log('推流消耗时间:' + ((+ new Date() - this.plugFlowStartDate) / 1000) + '秒')
-                        this.$refs.rtcMediaPlayer.play().then(() => {
-                            this.$refs.rtcMediaPlayer.volume = 1
-                        }).catch(error => {
-                            Dialog.alert({
-                                title: '提示',
-                                message: '加载失败,请手动刷新',
-                                confirmButtonText: '刷新',
-                                confirmButtonColor: '#3cc51f',
-                                beforeClose: (action, done) => {
-                                    this.$refs.rtcMediaPlayer.play()
-                                    this.$refs.rtcMediaPlayer.volume = 1
-                                    done()
-                                }
-                            })
-                            // Toast('如需声音,可调高音量使用')
-                            console.error('自动播放失败', error);
-                        });
+                        this.$refs.rtcMediaPlayer.muted = true
+                        this.$refs.rtcMediaPlayer.play()
                         this.definitionFun(this.definitionValue)
                         this.pushflowPopup()
                         this.getResidueTime()
@@ -309,7 +292,7 @@ const app = new Vue({
         // 清晰度
         definitionFun(value) {
             this.definitionValue = value
-            this.engine.makeBitrate(value)
+            this.engine.makeBitrate && this.engine.makeBitrate(value)
             localStorage.setItem('definitionValue', value)
             this.levitatedSphereVisible = false
         },
@@ -331,7 +314,7 @@ const app = new Vue({
         // 确定修改分辨率
         confirmResolution() {
             let { width, height, dpi: density } = this.phoneSize
-            this.engine.makeResolution({ width, height, density })
+            this.engine.makeResolution && this.engine.makeResolution({ width, height, density })
             this.resolutionRatioVisible = false
         },
 
@@ -748,13 +731,13 @@ const app = new Vue({
         },
         // 移开手指时会发生的回调
         touchendRtcMediaPlayer(event) {
-            this.engine.touchClick(event, 1, true)
+            this.engine.touchClick && this.engine.touchClick(event, 1, true)
             this.noOperationSetTimeout()
         },
 
         // 返回、主页、任务器
         footerBtnFun(key) {
-            this.engine[key]()
+            this.engine[key] && this.engine[key]()
             this.noOperationSetTimeout()
         },
 
@@ -769,6 +752,12 @@ const app = new Vue({
                 this.layoutViewWidth = layoutView.offsetWidth
                 this.layoutViewHeight = layoutView.offsetHeight
             })
+        },
+
+        // 音量
+        volumeControl(value) {
+            this.engine.ExexuteKeyBoard && this.engine.ExexuteKeyBoard(value)
+            this.$refs.rtcMediaPlayer && (this.$refs.rtcMediaPlayer.muted = false)
         }
     }
 })