@ai-matrx/meet 0.11.35 → 0.11.36

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.
package/dist/index.js CHANGED
@@ -4482,6 +4482,7 @@ function createLiveKitDriver(handlers, options = {}) {
4482
4482
  projectRoster = roster;
4483
4483
  created.on(RoomEvent.TrackSubscribed, (track) => {
4484
4484
  if (track.kind !== Track.Kind.Audio || typeof document === "undefined") return;
4485
+ if (!remoteAudioPlayback) return;
4485
4486
  const element = track.attach();
4486
4487
  element.setAttribute("data-mx-meet-audio", "");
4487
4488
  audioSink().appendChild(element);
@@ -4566,6 +4567,7 @@ function createLiveKitDriver(handlers, options = {}) {
4566
4567
  let sources = null;
4567
4568
  let trackEvents = null;
4568
4569
  let audioContainer = null;
4570
+ let remoteAudioPlayback = true;
4569
4571
  function audioSink() {
4570
4572
  if (audioContainer !== null && audioContainer.isConnected) return audioContainer;
4571
4573
  const container = document.createElement("div");
@@ -4724,6 +4726,14 @@ function createLiveKitDriver(handlers, options = {}) {
4724
4726
  throw normalizeDeviceError(error, "meet.switchDevice");
4725
4727
  }
4726
4728
  },
4729
+ setRemoteAudioPlayback(enabled) {
4730
+ remoteAudioPlayback = enabled;
4731
+ if (enabled || audioContainer === null) return;
4732
+ for (const element of Array.from(audioContainer.querySelectorAll("[data-mx-meet-audio]"))) {
4733
+ if (element instanceof HTMLMediaElement) element.srcObject = null;
4734
+ element.remove();
4735
+ }
4736
+ },
4727
4737
  async startAudio() {
4728
4738
  const target = room;
4729
4739
  if (target === null) return;
@@ -6628,6 +6638,7 @@ function createRoomEngine(options) {
6628
6638
  return;
6629
6639
  }
6630
6640
  driver = created;
6641
+ if (token.connectionKind === "companion") created.setRemoteAudioPlayback?.(false);
6631
6642
  await created.connect(token.serverUrl, token.token);
6632
6643
  store.patch({ failure: null, connection: "stable" });
6633
6644
  store.dispatch({ type: "connected" });
@@ -6889,6 +6900,19 @@ function createRoomEngine(options) {
6889
6900
  }
6890
6901
  },
6891
6902
  leave: leaveRoom,
6903
+ async checkElsewhere(roomName) {
6904
+ const claim = options.tabClaim;
6905
+ const userId = identity.userId;
6906
+ if (claim === void 0 || userId === null) return false;
6907
+ const before = store.snapshot();
6908
+ if (before.phase !== "prejoin" || before.secondDevice !== null) return false;
6909
+ if (!await claim.presentElsewhere(String(roomName), `user:${String(userId)}`)) return false;
6910
+ const now2 = store.snapshot();
6911
+ if (now2.phase !== "prejoin" || now2.secondDevice !== null) return false;
6912
+ store.patch({ secondDevice: { rule: "ask_switch_or_join" } });
6913
+ report("info", "meet: this browser already has you in this meeting \u2014 offering the choice before Join");
6914
+ return true;
6915
+ },
6892
6916
  backToPrejoin() {
6893
6917
  store.dispatch({ type: "back_to_prejoin", click: true });
6894
6918
  },