瀏覽代碼

学员进入房间同步节拍器状态

zouxuan 5 年之前
父節點
當前提交
f12b8f86bf

+ 2 - 0
mec-im/src/main/java/com/ym/mec/im/message/MemberChangedMessage.java

@@ -20,6 +20,8 @@ public class MemberChangedMessage extends BaseMessage {
     @Getter @Setter private String userName;
     @Getter @Setter private boolean camera;
     @Getter @Setter private boolean microphone;
+    @Getter @Setter private boolean metronomeSwitch;
+    @Getter @Setter private boolean handUpOn;
 
     private @Getter @Setter int role;
 

+ 16 - 0
mec-im/src/main/java/com/ym/service/Impl/RoomServiceImpl.java

@@ -1,6 +1,7 @@
 package com.ym.service.Impl;
 
 import com.alibaba.fastjson.JSONObject;
+import com.sun.org.apache.xpath.internal.operations.Bool;
 import com.ym.common.ApiException;
 import com.ym.common.DisplayEnum;
 import com.ym.common.ErrorEnum;
@@ -180,6 +181,7 @@ public class RoomServiceImpl implements RoomService {
         List<RoomMember> memberList = roomMemberDao.findByRidAndUid(roomId, userId);
         String midi = courseScheduleStudentPaymentDao.getMidiByCourseIdAndUserId(roomId.substring(1),userId);
         userResult.setPlayMidiJson(JSONObject.parseObject(midi,CustomMessage.class));
+        Boolean handUp = false;
         if (memberList.isEmpty()) {
             int count = roomMemberDao.countByRidAndExcludeRole(roomId, RoleEnum.RoleAudience.getValue());
             if (!isAudience && count == roomProperties.getMaxCount()) {
@@ -210,6 +212,7 @@ public class RoomServiceImpl implements RoomService {
             }
 //            roomMemberDao.updateCameraByRidAndUid(roomId, userId, !isDisableCamera);
             userResult.setCamera(roomMember.isCamera());
+            handUp = roomMember.isHand();
             userResult.setHandUp(roomMember.isHand());
             userResult.setJoinTime(roomMember.getJoinDt());
             log.info("user exist in the room: roomId={} , userId={}, use the last role={}", roomId, userId, roleEnum);
@@ -219,6 +222,19 @@ public class RoomServiceImpl implements RoomService {
         msg.setTimestamp(curTime);
         msg.setUserName(userName);
         msg.setCamera(!isDisableCamera);
+        Boolean playMidi = false;
+        if(roleEnum == RoleEnum.RoleStudent){
+            String midiByCourseIdAndUserId = courseScheduleStudentPaymentDao.getMidiByCourseIdAndUserId(courseSchedule.getId().toString(), userId);
+            //获取节拍器信息
+            if(StringUtils.isNotEmpty(midiByCourseIdAndUserId)){
+                JSONObject jsonObject = JSONObject.parseObject(midiByCourseIdAndUserId);
+                if(jsonObject.get("enable") != null){
+                    playMidi = Boolean.parseBoolean(jsonObject.get("enable").toString());
+                }
+            }
+        }
+        msg.setHandUpOn(handUp);
+        msg.setMetronomeSwitch(playMidi);
         imHelper.publishMessage(userId, roomId, msg);
         if (roleEnum == RoleEnum.RoleTeacher) {
             display = "display://type=1?userId=" + userId + "?uri=";