Procházet zdrojové kódy

增加老师端连麦模式控制同步逻辑

Pq před 2 roky
rodič
revize
83a97c4647

+ 8 - 0
student/src/main/java/com/cooleshow/student/bean/LiveRoomInfoBean.java

@@ -54,6 +54,8 @@ public class LiveRoomInfoBean implements Parcelable {
     public String tenantName;
     public int totalLookNum;
     public int blacklistFlag;//当前登录人是否是黑名单用户 0否 1是
+    public int whether_mic;//是否允许连麦
+    public int whether_chat;//是否允许聊天
 
     @Override
     public int describeContents() {
@@ -84,6 +86,8 @@ public class LiveRoomInfoBean implements Parcelable {
         dest.writeString(this.tenantName);
         dest.writeInt(this.totalLookNum);
         dest.writeInt(this.blacklistFlag);
+        dest.writeInt(this.whether_mic);
+        dest.writeInt(this.whether_chat);
     }
 
     public void readFromParcel(Parcel source) {
@@ -109,6 +113,8 @@ public class LiveRoomInfoBean implements Parcelable {
         this.tenantName = source.readString();
         this.totalLookNum = source.readInt();
         this.blacklistFlag = source.readInt();
+        this.whether_mic = source.readInt();
+        this.whether_chat = source.readInt();
     }
 
     public LiveRoomInfoBean() {
@@ -137,6 +143,8 @@ public class LiveRoomInfoBean implements Parcelable {
         this.tenantName = in.readString();
         this.totalLookNum = in.readInt();
         this.blacklistFlag = in.readInt();
+        this.whether_mic = in.readInt();
+        this.whether_chat = in.readInt();
     }
 
     public static final Creator<LiveRoomInfoBean> CREATOR = new Creator<LiveRoomInfoBean>() {

+ 4 - 1
student/src/main/java/com/cooleshow/student/ui/live/LiveRoomActivity.java

@@ -857,6 +857,10 @@ public class LiveRoomActivity extends BaseMVPActivity<ActivityLiveroomLayoutBind
         isPcClientLive = TextUtils.equals(mRoomInfoBean.os, "pc");
         resetVideoContainer(!isPcClientLive);
         currentAddLikeCount = roomInfoBean.likeNum;
+        //连麦模式
+        isEnableMic = roomInfoBean.whether_mic == 1;
+        //聊天模式
+        isEnableChat = roomInfoBean.whether_chat == 1;
         if (!TextUtils.isEmpty(roomInfoBean.roomConfig)) {
             try {
                 JSONObject jsonObject = new JSONObject(roomInfoBean.roomConfig);
@@ -1994,7 +1998,6 @@ public class LiveRoomActivity extends BaseMVPActivity<ActivityLiveroomLayoutBind
                 joinUserId = joinRoomMessage.getUserInfo().getUserId();
             }
         }
-        Log.i("pq","joinUserId:"+joinUserId);
         if (!TextUtils.isEmpty(joinUserId) && mRoomInfoBean != null) {
             if (TextUtils.equals(joinUserId, mRoomInfoBean.speakerId)) {
                 //老师加入直播,重置连麦申请中状态

+ 9 - 0
teacher/src/main/java/com/cooleshow/teacher/api/APIService.java

@@ -728,6 +728,15 @@ public interface APIService {
     @POST(TEACHER_GROUP + "liveRoom/syncUserStatus")
     Observable<BaseResponse<Object>> notifyLeaveRoomAction(@Body RequestBody body);
 
+
+    /**
+     * 同步服务端连麦模式 是否连麦 0:允许连麦 1禁止连麦模式
+     *
+     * @return
+     */
+    @GET(TEACHER_GROUP + "liveRoom/whetherMic")
+    Observable<BaseResponse<Object>> syncMicMode(@Query("roomUid") String roomUid, @Query("whetherMic") int whetherMic);
+
     /**
      * 通知(关闭/开启)直播录像
      *

+ 27 - 0
teacher/src/main/java/com/cooleshow/teacher/presenter/live/LiveRoomPresenter.java

@@ -800,6 +800,33 @@ public class LiveRoomPresenter extends BasePresenter<LiveRoomContract.LiveRoomVi
         });
     }
 
+    public void syncMicMode(String roomId, int micMode) {
+        create(APIService.class).syncMicMode(roomId, micMode)
+                .subscribeOn(Schedulers.io())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribe(new Observer<BaseResponse<Object>>() {
+                    @Override
+                    public void onSubscribe(Disposable d) {
+
+                    }
+
+                    @Override
+                    public void onNext(BaseResponse<Object> objectBaseResponse) {
+                        //通知服务端离开即可,无须关注结果
+                    }
+
+                    @Override
+                    public void onError(Throwable e) {
+
+                    }
+
+                    @Override
+                    public void onComplete() {
+                        //通知服务端离开即可,无须关注结果
+                    }
+                });
+    }
+
     /**
      * 通知服务端离开直播间
      */

+ 2 - 0
teacher/src/main/java/com/cooleshow/teacher/ui/live/TeacherLiveRoomActivity.java

@@ -1360,6 +1360,8 @@ public class TeacherLiveRoomActivity extends BaseMVPActivity<ActivityTeacherLive
                         updateMicManagerData();
                     }
                     if (presenter != null) {
+                        //1禁止连麦 0否
+                        presenter.syncMicMode(mRoomId, isEnable ? 1 : 0);
                         presenter.handleAction(LiveRoomMsgConstants.ACTION_SWITCH_MIC_MODE, isEnable);
                     }
                 }