Skip to content

Commit 2572ba9

Browse files
jallamsetty1damencho
authored andcommitted
fix(tracks) Always add audio track on Safari.
This fixes an issue where Safari users cannot hear remote audio if they join audio/video muted. The browser throws the following error when the application tries to execute play on the audio element: 'NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.' This started happening in Safari 15.
1 parent fc6e8fd commit 2572ba9

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

conference.js

+8-9
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ import {
5959
setAudioOutputDeviceId,
6060
updateDeviceList
6161
} from './react/features/base/devices';
62-
import { isIosMobileBrowser } from './react/features/base/environment/utils';
6362
import {
6463
browser,
6564
isFatalJitsiConnectionError,
@@ -835,9 +834,9 @@ export default {
835834
this._initDeviceList(true);
836835

837836
if (initialOptions.startWithAudioMuted) {
838-
// Always add the audio track to the peer connection and then mute the track on mobile Safari
839-
// because of a known issue where audio playout doesn't happen if the user joins audio and video muted.
840-
if (isIosMobileBrowser()) {
837+
// Always add the track on Safari because of a known issue where audio playout doesn't happen
838+
// if the user joins audio and video muted, i.e., if there is no local media capture.
839+
if (browser.isWebKitBased()) {
841840
this.muteAudio(true, true);
842841
} else {
843842
localTracks = localTracks.filter(track => track.getType() !== MEDIA_TYPE.AUDIO);
@@ -1357,8 +1356,8 @@ export default {
13571356
APP.conference.roomName,
13581357
this._getConferenceOptions());
13591358

1360-
// Filter out the tracks that are muted (except on mobile Safari).
1361-
const tracks = isIosMobileBrowser() ? localTracks : localTracks.filter(track => !track.isMuted());
1359+
// Filter out the tracks that are muted (except on Safari).
1360+
const tracks = browser.isWebKitBased() ? localTracks : localTracks.filter(track => !track.isMuted());
13621361

13631362
this._setLocalAudioVideoStreams(tracks);
13641363
this._room = room; // FIXME do not use this
@@ -2295,9 +2294,9 @@ export default {
22952294

22962295
// Remove the tracks from the peerconnection.
22972296
for (const track of localTracks) {
2298-
// Always add the track on mobile Safari because of a known issue where audio playout doesn't happen
2299-
// if the user joins audio and video muted.
2300-
if (audioMuted && track.jitsiTrack?.getType() === MEDIA_TYPE.AUDIO && !isIosMobileBrowser()) {
2297+
// Always add the track on Safari because of a known issue where audio playout doesn't happen
2298+
// if the user joins audio and video muted, i.e., if there is no local media capture.
2299+
if (audioMuted && track.jitsiTrack?.getType() === MEDIA_TYPE.AUDIO && !browser.isWebKitBased()) {
23012300
promises.push(this.useAudioStream(null));
23022301
}
23032302
if (videoMuted && track.jitsiTrack?.getType() === MEDIA_TYPE.VIDEO) {

0 commit comments

Comments
 (0)