call-live-sdk1 0.0.31 → 0.0.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -202796,8 +202796,8 @@ const useVideoSlotBinding = ({
202796
202796
  return;
202797
202797
  }
202798
202798
  const [, streamIndex = "main"] = selectedValue.split(fenge);
202799
- if (!targetUser || streamIndex === "screen" && !targetUser.isScreenEnabled) {
202800
- console.log(`用户${item.userId}已退出,恢复为空连麦嘉宾`);
202799
+ if (!targetUser || streamIndex === "screen" && !targetUser.isScreenEnabled || targetUser.waiting_mode_state === WaitingModeState.WAITING) {
202800
+ console.log(`用户${item.userId}已退出或被移至等候状态,恢复为空连麦嘉宾`);
202801
202801
  setSelectedValue("");
202802
202802
  try {
202803
202803
  livePlayerRef.current.addEmptyVideoSlot({ id: item.id });
@@ -202847,6 +202847,48 @@ const useVideoSlotBinding = ({
202847
202847
  livePlayerRef,
202848
202848
  getter
202849
202849
  ]);
202850
+ reactExports.useEffect(() => {
202851
+ const handleLocalCameraChanged = () => {
202852
+ var _a2;
202853
+ if (item.objectType !== "videoSlot" || !selectedValue || !livePlayerRef.current)
202854
+ return;
202855
+ const [userId] = selectedValue.split(fenge);
202856
+ const { callConfig } = useCallStore.getState();
202857
+ if (userId !== callConfig.rtc_userid)
202858
+ return;
202859
+ console.log("检测到本地摄像头切换,重新绑定视频槽:", item.id);
202860
+ const canvas = getter().fabricInstance;
202861
+ if (!canvas) {
202862
+ console.error("画布未初始化");
202863
+ return;
202864
+ }
202865
+ const videoSlotObj = (_a2 = canvas.getObjects()) == null ? void 0 : _a2.find((o2) => o2.id === item.id);
202866
+ if (!videoSlotObj) {
202867
+ console.error("找不到对应的连麦嘉宾对象:", item.id);
202868
+ return;
202869
+ }
202870
+ const [, streamIndex = "main"] = selectedValue.split(fenge);
202871
+ const user = callUsers.find((user2) => user2.rtc_userid === userId);
202872
+ if (user && user.isVideoEnabled) {
202873
+ try {
202874
+ livePlayerRef.current.bindVideoSlotToFirstEmpty({
202875
+ id: item.id,
202876
+ userId,
202877
+ streamIndex: streamIndex === "screen" ? "screen" : "main",
202878
+ userName: user.nickname
202879
+ });
202880
+ videoSlotObj.userId = userId;
202881
+ videoSlotObj.streamIndex = streamIndex;
202882
+ } catch (bindError) {
202883
+ console.error("重新绑定视频流失败:", bindError);
202884
+ }
202885
+ }
202886
+ };
202887
+ eventBus.on("localCameraChanged", handleLocalCameraChanged);
202888
+ return () => {
202889
+ eventBus.off("localCameraChanged", handleLocalCameraChanged);
202890
+ };
202891
+ }, [item, selectedValue, fenge, livePlayerRef, getter, callUsers]);
202850
202892
  return {
202851
202893
  selectedValue,
202852
202894
  setSelectedValue,
@@ -279779,6 +279821,9 @@ const MediaSettings = () => {
279779
279821
  cameraId: newCameraId
279780
279822
  }
279781
279823
  });
279824
+ eventBus.emit("localCameraChanged", {
279825
+ cameraId: newCameraId
279826
+ });
279782
279827
  } else {
279783
279828
  console.error("摄像头切换失败:", result.message);
279784
279829
  staticMethods.error("摄像头切换失败");
@@ -301593,7 +301638,7 @@ const useRoomMessageHandler = (params = {}) => {
301593
301638
  case "leave":
301594
301639
  return `${type4}`;
301595
301640
  case "waiting_mode":
301596
- return `${type4}_${(data2 == null ? void 0 : data2.rtc_userid) || userId}_${(data2 == null ? void 0 : data2.waiting_mode_state) || "unknown"}`;
301641
+ return `${type4}_${(data2 == null ? void 0 : data2.rtc_userid) || userId}_${(data2 == null ? void 0 : data2.waiting_mode_state) || "unknown"}_${Date.now()}`;
301597
301642
  case "change_user":
301598
301643
  return `${type4}_${userId}_${(data2 == null ? void 0 : data2.action) || "unknown"}`;
301599
301644
  case "media":
@@ -301720,16 +301765,33 @@ const useRoomMessageHandler = (params = {}) => {
301720
301765
  }
301721
301766
  if (waiting_mode_state === WaitingModeState.ADMITTED) {
301722
301767
  console.log("收到准入消息", waitingData);
301723
- if (users) {
301768
+ let userFoundInArray = false;
301769
+ if (users && Array.isArray(users)) {
301724
301770
  users.forEach((user) => {
301725
301771
  if (user.rtc_userid === rtc_userid) {
301726
301772
  user.waiting_mode_state = waiting_mode_state;
301773
+ userFoundInArray = true;
301774
+ console.log("在 users 数组中找到目标用户,更新状态", user);
301727
301775
  }
301728
301776
  if (user.rtc_userid) {
301729
301777
  updateCallUser(user.rtc_userid, user);
301730
301778
  }
301731
301779
  });
301732
301780
  }
301781
+ if (!userFoundInArray) {
301782
+ console.warn("users 数组中未找到目标用户,直接使用消息数据更新状态", {
301783
+ rtc_userid,
301784
+ waiting_mode_state,
301785
+ users
301786
+ });
301787
+ updateCallUser(rtc_userid, {
301788
+ waiting_mode_state: WaitingModeState.ADMITTED
301789
+ });
301790
+ console.log("已直接更新用户状态为 ADMITTED", {
301791
+ rtc_userid,
301792
+ waiting_mode_state: WaitingModeState.ADMITTED
301793
+ });
301794
+ }
301733
301795
  }
301734
301796
  } catch (error2) {
301735
301797
  console.error("处理等候模式消息失败", {
@@ -304978,7 +305040,7 @@ const UserVideoContainer = reactExports.memo(({
304978
305040
  noMirror,
304979
305041
  shouldMirror: +!noMirror
304980
305042
  });
304981
- const isModeFit = user.rtc_userid === callConfig.drawing_board_id || (videoId == null ? void 0 : videoId.includes("screen")) || user.device === "pc";
305043
+ const isModeFit = user.rtc_userid === callConfig.drawing_board_id || (videoId == null ? void 0 : videoId.includes("screen")) || user.device === "pc" || videoId.includes("self");
304982
305044
  window.log.push({
304983
305045
  com: "UserVideoContainer",
304984
305046
  params: {