From 2572ba9a65569544abcf434f4e63a1a130108f46 Mon Sep 17 00:00:00 2001 From: Jaya Allamsetty Date: Tue, 5 Oct 2021 12:40:19 -0400 Subject: [PATCH] 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. --- conference.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/conference.js b/conference.js index e499988661d2..2428ec89eb74 100644 --- a/conference.js +++ b/conference.js @@ -59,7 +59,6 @@ import { setAudioOutputDeviceId, updateDeviceList } from './react/features/base/devices'; -import { isIosMobileBrowser } from './react/features/base/environment/utils'; import { browser, isFatalJitsiConnectionError, @@ -835,9 +834,9 @@ export default { this._initDeviceList(true); if (initialOptions.startWithAudioMuted) { - // Always add the audio track to the peer connection and then mute the track on mobile Safari - // because of a known issue where audio playout doesn't happen if the user joins audio and video muted. - if (isIosMobileBrowser()) { + // Always add the track on Safari because of a known issue where audio playout doesn't happen + // if the user joins audio and video muted, i.e., if there is no local media capture. + if (browser.isWebKitBased()) { this.muteAudio(true, true); } else { localTracks = localTracks.filter(track => track.getType() !== MEDIA_TYPE.AUDIO); @@ -1357,8 +1356,8 @@ export default { APP.conference.roomName, this._getConferenceOptions()); - // Filter out the tracks that are muted (except on mobile Safari). - const tracks = isIosMobileBrowser() ? localTracks : localTracks.filter(track => !track.isMuted()); + // Filter out the tracks that are muted (except on Safari). + const tracks = browser.isWebKitBased() ? localTracks : localTracks.filter(track => !track.isMuted()); this._setLocalAudioVideoStreams(tracks); this._room = room; // FIXME do not use this @@ -2295,9 +2294,9 @@ export default { // Remove the tracks from the peerconnection. for (const track of localTracks) { - // Always add the track on mobile Safari because of a known issue where audio playout doesn't happen - // if the user joins audio and video muted. - if (audioMuted && track.jitsiTrack?.getType() === MEDIA_TYPE.AUDIO && !isIosMobileBrowser()) { + // Always add the track on Safari because of a known issue where audio playout doesn't happen + // if the user joins audio and video muted, i.e., if there is no local media capture. + if (audioMuted && track.jitsiTrack?.getType() === MEDIA_TYPE.AUDIO && !browser.isWebKitBased()) { promises.push(this.useAudioStream(null)); } if (videoMuted && track.jitsiTrack?.getType() === MEDIA_TYPE.VIDEO) {