瀏覽代碼

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 年之前
父節點
當前提交
b9866e3464
共有 2 個檔案被更改,包括 19 行新增6 行删除
  1. 13
    4
      conference.js
  2. 6
    2
      react/features/prejoin/middleware.js

+ 13
- 4
conference.js 查看文件

56
     setAudioOutputDeviceId,
56
     setAudioOutputDeviceId,
57
     updateDeviceList
57
     updateDeviceList
58
 } from './react/features/base/devices';
58
 } from './react/features/base/devices';
59
+import { isIosMobileBrowser } from './react/features/base/environment/utils';
59
 import {
60
 import {
60
     browser,
61
     browser,
61
     isFatalJitsiConnectionError,
62
     isFatalJitsiConnectionError,
834
         this._initDeviceList(true);
835
         this._initDeviceList(true);
835
 
836
 
836
         if (initialOptions.startWithAudioMuted) {
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
         return this.startConference(con, localTracks);
847
         return this.startConference(con, localTracks);
1322
 
1329
 
1323
         APP.store.dispatch(conferenceWillJoin(room));
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
         this._setLocalAudioVideoStreams(tracks);
1335
         this._setLocalAudioVideoStreams(tracks);
1329
         this._room = room; // FIXME do not use this
1336
         this._room = room; // FIXME do not use this
2261
 
2268
 
2262
             // Remove the tracks from the peerconnection.
2269
             // Remove the tracks from the peerconnection.
2263
             for (const track of localTracks) {
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
                     promises.push(this.useAudioStream(null));
2274
                     promises.push(this.useAudioStream(null));
2266
                 }
2275
                 }
2267
                 if (videoMuted && track.jitsiTrack?.getType() === MEDIA_TYPE.VIDEO) {
2276
                 if (videoMuted && track.jitsiTrack?.getType() === MEDIA_TYPE.VIDEO) {

+ 6
- 2
react/features/prejoin/middleware.js 查看文件

2
 
2
 
3
 import { CONFERENCE_JOINED } from '../base/conference';
3
 import { CONFERENCE_JOINED } from '../base/conference';
4
 import { updateConfig } from '../base/config';
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
 import { MiddlewareRegistry } from '../base/redux';
7
 import { MiddlewareRegistry } from '../base/redux';
7
 import { updateSettings } from '../base/settings';
8
 import { updateSettings } from '../base/settings';
8
 import {
9
 import {
46
 
47
 
47
         // Do not signal audio/video tracks if the user joins muted.
48
         // Do not signal audio/video tracks if the user joins muted.
48
         for (const track of localTracks) {
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
                 await dispatch(replaceLocalTrack(track.jitsiTrack, null));
54
                 await dispatch(replaceLocalTrack(track.jitsiTrack, null));
51
             }
55
             }
52
         }
56
         }

Loading…
取消
儲存