Explorar o código

直播连麦全屏问题修复

yindan %!s(int64=2) %!d(string=hai) anos
pai
achega
e63265d702
Modificáronse 2 ficheiros con 47 adicións e 14 borrados
  1. 43 14
      pages/live/live.js
  2. 4 0
      pages/live/live.wxss

+ 43 - 14
pages/live/live.js

@@ -174,8 +174,24 @@ Page({
         // this.storeBindings.destroyStoreBindings();
     },
     changeFull(e) {
-        let playerList = this.data.playerList[this.data.bigIndex];
-        this.rotate();
+        let verticalFullScreen = this.data.bigIndex === -1;
+        if(!verticalFullScreen) {
+            let currentBigerPlayer = this.data.playerList[this.data.bigIndex];
+            // let livePlayerContext = EduTRTC.getInstance().getPlayerInstance(playerList.id);
+            const {videoWidth, videoHeight} = currentBigerPlayer.netStatus;
+           if(videoWidth && videoHeight && videoHeight > videoWidth) {
+               verticalFullScreen = true;
+           }
+        }
+        if(verticalFullScreen) {
+            this.setData({
+                isFull: !this.data.isFull
+            });
+        } else {
+            this.rotate();
+        }
+        // let playerList = this.data.playerList[this.data.bigIndex];
+        // this.rotate();
         // if (this.data.bigIndex==-1 || playerList.userID.indexOf("student") !=-1
         //     || playerList.userID.indexOf("guest_") !=-1 ){
         //     this.setData({
@@ -290,9 +306,16 @@ Page({
         let that = this;
         let playerList = this.data.playerList[this.data.bigIndex];
         let livePlayerContext = wx.createLivePlayerContext(playerList.id);
-        console.log(livePlayerContext)
+        // let livePlayerContext = EduTRTC.getInstance().getPlayerInstance(playerList.id);
+        const {videoWidth, videoHeight} = playerList.netStatus;
+        // if(!videoWidth || !videoHeight) {
+        //     toast("网络状态不好,请稍后再试!");
+        //     return;
+        // }
+        const direction = videoWidth && videoHeight > videoWidth? 0 : 90;
         livePlayerContext.requestFullScreen({
-            direction:90,
+            // direction: 90,
+            direction,
             success(res) {
                 that.setData({isRotate:true})
             },
@@ -309,16 +332,22 @@ Page({
         let that = this;
         let playerList = this.data.playerList[this.data.bigIndex];
         let livePlayerContext = wx.createLivePlayerContext(playerList.id);
-        console.log(livePlayerContext)
-        livePlayerContext.exitFullScreen({
-            success(res) {
-                that.setData({isRotate:false})
-            },
-            fail(e){
-                toast("屏幕旋转失败,请稍后重试")
-                console.log(e)
-            }
-        })
+        // 解决退出全屏后 屏幕还是在旋转状态的问题 --- start
+        livePlayerContext.requestFullScreen({
+            direction: 0
+        });
+        // 解决退出全屏后 屏幕还是在旋转状态的问题 --- end
+        wx.nextTick(() => {
+            livePlayerContext.exitFullScreen({
+                success(res) {
+                    that.setData({isRotate:false})
+                },
+                fail(e){
+                    toast("屏幕旋转失败,请稍后重试")
+                    console.log(e)
+                }
+            })
+        });
     },
 
 

+ 4 - 0
pages/live/live.wxss

@@ -61,6 +61,10 @@ page {
     display: flex;
     flex-direction: row;
     white-space: nowrap;
+    /* display: none; */
+    /* width: 0;
+    height: 0; */
+    bottom: -500px;
 }