@azure/communication-react 1.10.1-alpha-202311110012 → 1.10.1-alpha-202311160012

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.
@@ -2316,6 +2316,10 @@ export declare type CallingSounds = {
2316
2316
  * Sound to be played when the call ends
2317
2317
  */
2318
2318
  callEnded?: SoundEffect;
2319
+ /**
2320
+ * Sound to be played when the call is ringing
2321
+ */
2322
+ callRinging?: SoundEffect;
2319
2323
  };
2320
2324
 
2321
2325
  /**
@@ -177,7 +177,7 @@ const _isValidIdentifier = (identifier) => {
177
177
  // Copyright (c) Microsoft Corporation.
178
178
  // Licensed under the MIT License.
179
179
  // GENERATED FILE. DO NOT EDIT MANUALLY.
180
- var telemetryVersion = '1.10.1-alpha-202311110012';
180
+ var telemetryVersion = '1.10.1-alpha-202311160012';
181
181
 
182
182
  // Copyright (c) Microsoft Corporation.
183
183
  /**
@@ -30059,27 +30059,30 @@ const createProfileStateModifier = (onFetchProfile, notifyUpdate) => {
30059
30059
  };
30060
30060
 
30061
30061
  // Copyright (c) Microsoft Corporation.
30062
- // Licensed under the MIT License.
30063
30062
  /**
30064
30063
  * @private
30065
30064
  */
30066
30065
  class CallingSoundSubscriber {
30067
- constructor(call, emitter, sounds) {
30066
+ constructor(call, locator, sounds) {
30068
30067
  this.onCallStateChanged = () => {
30069
30068
  this.call.on('stateChanged', () => {
30070
- var _a;
30071
- this.emitter.emit('callStateChanged', {
30072
- callState: this.call.state
30073
- });
30074
- if (this.call.state === 'Disconnected' && ((_a = this.soundsLoaded) === null || _a === void 0 ? void 0 : _a.callEndedSound)) {
30075
- this.soundsLoaded.callEndedSound.play().catch((e) => {
30076
- console.error(e, 'Failed to play call ended sound, check loader config to make sure it is correct');
30077
- });
30069
+ var _a, _b, _c;
30070
+ if (shouldPlayRingingSound(this.call, this.callLocator) && ((_a = this.soundsLoaded) === null || _a === void 0 ? void 0 : _a.callRingingSound)) {
30071
+ this.soundsLoaded.callRingingSound.loop = true;
30072
+ this.playSound(this.soundsLoaded.callRingingSound);
30073
+ }
30074
+ if ((this.call.state === 'Connected' || this.call.state === 'Disconnected') &&
30075
+ ((_b = this.soundsLoaded) === null || _b === void 0 ? void 0 : _b.callRingingSound)) {
30076
+ this.soundsLoaded.callRingingSound.loop = false;
30077
+ this.soundsLoaded.callRingingSound.pause();
30078
+ }
30079
+ if (this.call.state === 'Disconnected' && ((_c = this.soundsLoaded) === null || _c === void 0 ? void 0 : _c.callEndedSound)) {
30080
+ this.playSound(this.soundsLoaded.callEndedSound);
30078
30081
  }
30079
30082
  });
30080
30083
  };
30081
30084
  this.call = call;
30082
- this.emitter = emitter;
30085
+ this.callLocator = locator;
30083
30086
  if (sounds) {
30084
30087
  this.soundsLoaded = this.loadSounds(sounds);
30085
30088
  this.subscribeCallSoundEvents();
@@ -30089,20 +30092,52 @@ class CallingSoundSubscriber {
30089
30092
  this.onCallStateChanged();
30090
30093
  }
30091
30094
  unsubscribeAll() {
30095
+ var _a;
30092
30096
  this.call.off('stateChanged', this.onCallStateChanged);
30097
+ if ((_a = this.soundsLoaded) === null || _a === void 0 ? void 0 : _a.callRingingSound) {
30098
+ this.soundsLoaded.callRingingSound.pause();
30099
+ }
30093
30100
  }
30094
30101
  loadSounds(sounds) {
30095
- var _a;
30102
+ var _a, _b;
30096
30103
  let callEndedSound;
30097
30104
  if (sounds === null || sounds === void 0 ? void 0 : sounds.callEnded) {
30098
30105
  callEndedSound = new Audio((_a = sounds === null || sounds === void 0 ? void 0 : sounds.callEnded) === null || _a === void 0 ? void 0 : _a.path);
30099
30106
  callEndedSound.preload = 'auto';
30100
30107
  }
30108
+ let callRingingSound;
30109
+ if (sounds === null || sounds === void 0 ? void 0 : sounds.callRinging) {
30110
+ callRingingSound = new Audio((_b = sounds === null || sounds === void 0 ? void 0 : sounds.callRinging) === null || _b === void 0 ? void 0 : _b.path);
30111
+ callRingingSound.preload = 'auto';
30112
+ }
30101
30113
  return {
30102
- callEndedSound
30114
+ callEndedSound,
30115
+ callRingingSound
30103
30116
  };
30104
30117
  }
30118
+ playSound(sound) {
30119
+ sound.play().catch((e) => {
30120
+ console.error(e, 'Failed to play sound, check loader config to make sure it is correct');
30121
+ });
30122
+ }
30105
30123
  }
30124
+ /**
30125
+ * Helper function to allow the calling sound subscriber to determine when to play the ringing
30126
+ * sound when making an outbound call.
30127
+ */
30128
+ const shouldPlayRingingSound = (call, locator) => {
30129
+ /* @conditional-compile-remove(calling-sounds) */
30130
+ const callee = locator.participantIds;
30131
+ /* @conditional-compile-remove(calling-sounds) */
30132
+ if (callee.length >= 1 &&
30133
+ !communicationCommon.isPhoneNumberIdentifier(fromFlatCommunicationIdentifier(callee[0])) &&
30134
+ (call.state === 'Ringing' || call.state === 'Connecting')) {
30135
+ return true;
30136
+ }
30137
+ else {
30138
+ return false;
30139
+ }
30140
+ };
30106
30141
 
30107
30142
  // Copyright (c) Microsoft Corporation.
30108
30143
  // Licensed under the MIT License.
@@ -30921,7 +30956,7 @@ class AzureCommunicationCallAdapter {
30921
30956
  var _a, _b, _c, _d, _e, _f, _g;
30922
30957
  /* @conditional-compile-remove(calling-sounds) */
30923
30958
  if (this.call) {
30924
- this.callingSoundSubscriber = new CallingSoundSubscriber(this.call, this.emitter, this.getState().sounds);
30959
+ this.callingSoundSubscriber = new CallingSoundSubscriber(this.call, this.locator, this.getState().sounds);
30925
30960
  }
30926
30961
  (_a = this.call) === null || _a === void 0 ? void 0 : _a.on('remoteParticipantsUpdated', this.onRemoteParticipantsUpdated.bind(this));
30927
30962
  (_b = this.call) === null || _b === void 0 ? void 0 : _b.on('isMutedChanged', this.isMyMutedChanged.bind(this));