livekit-client 1.6.8 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -13940,7 +13940,7 @@ var uaParser = {
13940
13940
  })(uaParser, uaParserExports);
13941
13941
  var UAParser = uaParserExports;
13942
13942
 
13943
- var version$1 = "1.6.8";
13943
+ var version$1 = "1.7.0";
13944
13944
 
13945
13945
  const version = version$1;
13946
13946
  const protocolVersion = 9;
@@ -15000,7 +15000,11 @@ class Track extends eventsExports.EventEmitter {
15000
15000
  element.play().then(() => {
15001
15001
  this.emit(TrackEvent.AudioPlaybackStarted);
15002
15002
  }).catch(e => {
15003
- this.emit(TrackEvent.AudioPlaybackFailed, e);
15003
+ if (e.name === 'NotAllowedError') {
15004
+ this.emit(TrackEvent.AudioPlaybackFailed, e);
15005
+ } else {
15006
+ livekitLogger.warn('could not playback audio', e);
15007
+ }
15004
15008
  // If audio playback isn't allowed make sure we still play back the video
15005
15009
  if (element && allMediaStreamTracks.some(tr => tr.kind === 'video') && e.name === 'NotAllowedError') {
15006
15010
  element.muted = true;
@@ -16774,9 +16778,6 @@ class Participant extends eventsExports.EventEmitter {
16774
16778
  * @returns
16775
16779
  */
16776
16780
  getTrack(source) {
16777
- if (source === Track.Source.Unknown) {
16778
- return;
16779
- }
16780
16781
  for (const [, pub] of this.tracks) {
16781
16782
  if (pub.source === source) {
16782
16783
  return pub;
@@ -17669,6 +17670,11 @@ class LocalParticipant extends Participant {
17669
17670
  this.reconnectFuture = undefined;
17670
17671
  this.updateTrackSubscriptionPermissions();
17671
17672
  };
17673
+ this.handleDisconnected = () => {
17674
+ var _a, _b;
17675
+ (_b = (_a = this.reconnectFuture) === null || _a === void 0 ? void 0 : _a.reject) === null || _b === void 0 ? void 0 : _b.call(_a, 'Got disconnected during publishing attempt');
17676
+ this.reconnectFuture = undefined;
17677
+ };
17672
17678
  this.updateTrackSubscriptionPermissions = () => {
17673
17679
  livekitLogger.debug('updating track subscription permissions', {
17674
17680
  allParticipantsAllowed: this.allParticipantsAllowedToSubscribe,
@@ -17847,7 +17853,7 @@ class LocalParticipant extends Participant {
17847
17853
  };
17848
17854
  this.engine.client.onSubscribedQualityUpdate = this.handleSubscribedQualityUpdate;
17849
17855
  this.engine.client.onLocalTrackUnpublished = this.handleLocalTrackUnpublished;
17850
- this.engine.on(EngineEvent.Connected, this.handleReconnected).on(EngineEvent.Restarted, this.handleReconnected).on(EngineEvent.Resumed, this.handleReconnected).on(EngineEvent.Restarting, this.handleReconnecting).on(EngineEvent.Resuming, this.handleReconnecting);
17856
+ this.engine.on(EngineEvent.Connected, this.handleReconnected).on(EngineEvent.Restarted, this.handleReconnected).on(EngineEvent.Resumed, this.handleReconnected).on(EngineEvent.Restarting, this.handleReconnecting).on(EngineEvent.Resuming, this.handleReconnecting).on(EngineEvent.Disconnected, this.handleDisconnected);
17851
17857
  }
17852
17858
  /**
17853
17859
  * Enable or disable a participant's camera track.
@@ -21610,16 +21616,20 @@ class Room extends eventsExports.EventEmitter {
21610
21616
  * @param deviceId
21611
21617
  */
21612
21618
  async switchActiveDevice(kind, deviceId) {
21619
+ let exact = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
21613
21620
  var _a;
21614
21621
  var _b;
21622
+ const deviceConstraint = exact ? {
21623
+ exact: deviceId
21624
+ } : deviceId;
21615
21625
  if (kind === 'audioinput') {
21616
21626
  const prevDeviceId = this.options.audioCaptureDefaults.deviceId;
21617
- this.options.audioCaptureDefaults.deviceId = deviceId;
21627
+ this.options.audioCaptureDefaults.deviceId = deviceConstraint;
21618
21628
  const tracks = Array.from(this.localParticipant.audioTracks.values()).filter(track => track.source === Track.Source.Microphone);
21619
21629
  try {
21620
21630
  await Promise.all(tracks.map(t => {
21621
21631
  var _a;
21622
- return (_a = t.audioTrack) === null || _a === void 0 ? void 0 : _a.setDeviceId(deviceId);
21632
+ return (_a = t.audioTrack) === null || _a === void 0 ? void 0 : _a.setDeviceId(deviceConstraint);
21623
21633
  }));
21624
21634
  } catch (e) {
21625
21635
  this.options.audioCaptureDefaults.deviceId = prevDeviceId;
@@ -21627,12 +21637,12 @@ class Room extends eventsExports.EventEmitter {
21627
21637
  }
21628
21638
  } else if (kind === 'videoinput') {
21629
21639
  const prevDeviceId = this.options.videoCaptureDefaults.deviceId;
21630
- this.options.videoCaptureDefaults.deviceId = deviceId;
21640
+ this.options.videoCaptureDefaults.deviceId = deviceConstraint;
21631
21641
  const tracks = Array.from(this.localParticipant.videoTracks.values()).filter(track => track.source === Track.Source.Camera);
21632
21642
  try {
21633
21643
  await Promise.all(tracks.map(t => {
21634
21644
  var _a;
21635
- return (_a = t.videoTrack) === null || _a === void 0 ? void 0 : _a.setDeviceId(deviceId);
21645
+ return (_a = t.videoTrack) === null || _a === void 0 ? void 0 : _a.setDeviceId(deviceConstraint);
21636
21646
  }));
21637
21647
  } catch (e) {
21638
21648
  this.options.videoCaptureDefaults.deviceId = prevDeviceId;