Skip to content

Commit

Permalink
fix(tracks) Always add audio track on Safari.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jallamsetty1 authored and damencho committed Oct 5, 2021
1 parent fc6e8fd commit 2572ba9
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions conference.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ import {
setAudioOutputDeviceId,
updateDeviceList
} from './react/features/base/devices';
import { isIosMobileBrowser } from './react/features/base/environment/utils';
import {
browser,
isFatalJitsiConnectionError,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 2572ba9

Please sign in to comment.