Bläddra i källkod

fix(tracks) Fix mobile safari issue with startMuted.

On mobile Safari, when a user joins both audio and video muted, browser doesn't playout the remote audio because of a webkit bug. As a workaround, always add the audio track to peerconnection and then mute the track if needed.
master
Jaya Allamsetty 4 år sedan
förälder
incheckning
b9866e3464
2 ändrade filer med 19 tillägg och 6 borttagningar
  1. 13
    4
      conference.js
  2. 6
    2
      react/features/prejoin/middleware.js

+ 13
- 4
conference.js Visa fil

@@ -56,6 +56,7 @@ import {
56 56
     setAudioOutputDeviceId,
57 57
     updateDeviceList
58 58
 } from './react/features/base/devices';
59
+import { isIosMobileBrowser } from './react/features/base/environment/utils';
59 60
 import {
60 61
     browser,
61 62
     isFatalJitsiConnectionError,
@@ -834,7 +835,13 @@ export default {
834 835
         this._initDeviceList(true);
835 836
 
836 837
         if (initialOptions.startWithAudioMuted) {
837
-            localTracks = localTracks.filter(track => track.getType() !== MEDIA_TYPE.AUDIO);
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()) {
841
+                this.muteAudio(true, true);
842
+            } else {
843
+                localTracks = localTracks.filter(track => track.getType() !== MEDIA_TYPE.AUDIO);
844
+            }
838 845
         }
839 846
 
840 847
         return this.startConference(con, localTracks);
@@ -1322,8 +1329,8 @@ export default {
1322 1329
 
1323 1330
         APP.store.dispatch(conferenceWillJoin(room));
1324 1331
 
1325
-        // Filter out the tracks that are muted.
1326
-        const tracks = localTracks.filter(track => !track.isMuted());
1332
+        // Filter out the tracks that are muted (except on mobile Safari).
1333
+        const tracks = isIosMobileBrowser() ? localTracks : localTracks.filter(track => !track.isMuted());
1327 1334
 
1328 1335
         this._setLocalAudioVideoStreams(tracks);
1329 1336
         this._room = room; // FIXME do not use this
@@ -2261,7 +2268,9 @@ export default {
2261 2268
 
2262 2269
             // Remove the tracks from the peerconnection.
2263 2270
             for (const track of localTracks) {
2264
-                if (audioMuted && track.jitsiTrack?.getType() === MEDIA_TYPE.AUDIO) {
2271
+                // Always add the track on mobile Safari because of a known issue where audio playout doesn't happen
2272
+                // if the user joins audio and video muted.
2273
+                if (audioMuted && track.jitsiTrack?.getType() === MEDIA_TYPE.AUDIO && !isIosMobileBrowser()) {
2265 2274
                     promises.push(this.useAudioStream(null));
2266 2275
                 }
2267 2276
                 if (videoMuted && track.jitsiTrack?.getType() === MEDIA_TYPE.VIDEO) {

+ 6
- 2
react/features/prejoin/middleware.js Visa fil

@@ -2,7 +2,8 @@
2 2
 
3 3
 import { CONFERENCE_JOINED } from '../base/conference';
4 4
 import { updateConfig } from '../base/config';
5
-import { SET_AUDIO_MUTED, SET_VIDEO_MUTED } from '../base/media';
5
+import { isIosMobileBrowser } from '../base/environment/utils';
6
+import { MEDIA_TYPE, SET_AUDIO_MUTED, SET_VIDEO_MUTED } from '../base/media';
6 7
 import { MiddlewareRegistry } from '../base/redux';
7 8
 import { updateSettings } from '../base/settings';
8 9
 import {
@@ -46,7 +47,10 @@ MiddlewareRegistry.register(store => next => async action => {
46 47
 
47 48
         // Do not signal audio/video tracks if the user joins muted.
48 49
         for (const track of localTracks) {
49
-            if (track.muted) {
50
+            // Always add the audio track on mobile Safari because of a known issue where audio playout doesn't happen
51
+            // if the user joins audio and video muted.
52
+            if (track.muted
53
+                && !(isIosMobileBrowser() && track.jitsiTrack && track.jitsiTrack.getType() === MEDIA_TYPE.AUDIO)) {
50 54
                 await dispatch(replaceLocalTrack(track.jitsiTrack, null));
51 55
             }
52 56
         }

Laddar…
Avbryt
Spara