ソースを参照

Use unified plan for mobile browsers on iOS

All browsers on iOS use WebKit engine so they use the Unified Plan.
dev1
Jordan Owens 4年前
コミット
840302192a
1個のファイルの変更19行の追加7行の削除
  1. 19
    7
      modules/browser/BrowserCapabilities.js

+ 19
- 7
modules/browser/BrowserCapabilities.js ファイルの表示

@@ -64,6 +64,24 @@ export default class BrowserCapabilities extends BrowserDetection {
64 64
             || this.isOpera();
65 65
     }
66 66
 
67
+    /**
68
+     * Checks if the current browser is WebKit based. It's either
69
+     * Safari or uses WebKit as its engine.
70
+     *
71
+     * This includes Chrome and Firefox on iOS
72
+     *
73
+     * @returns {boolean}
74
+     */
75
+    isWebKitBased() {
76
+        // https://trac.webkit.org/changeset/236144/webkit/trunk/LayoutTests/webrtc/video-addLegacyTransceiver.html
77
+        return this._bowser.isEngine('webkit')
78
+            && typeof navigator.mediaDevices !== 'undefined'
79
+            && typeof navigator.mediaDevices.getUserMedia !== 'undefined'
80
+            && typeof window.RTCRtpTransceiver !== 'undefined'
81
+            // eslint-disable-next-line no-undef
82
+            && Object.keys(RTCRtpTransceiver.prototype).indexOf('currentDirection') > -1;
83
+    }
84
+
67 85
     /**
68 86
      * Checks whether current running context is a Trusted Web Application.
69 87
      *
@@ -208,16 +226,10 @@ export default class BrowserCapabilities extends BrowserDetection {
208 226
      * @returns {boolean}
209 227
      */
210 228
     usesUnifiedPlan() {
211
-        if (this.isFirefox()) {
229
+        if (this.isFirefox() || this.isWebKitBased()) {
212 230
             return true;
213 231
         }
214 232
 
215
-        if (this.isSafari() && typeof window.RTCRtpTransceiver !== 'undefined') {
216
-            // https://trac.webkit.org/changeset/236144/webkit/trunk/LayoutTests/webrtc/video-addLegacyTransceiver.html
217
-            // eslint-disable-next-line no-undef
218
-            return Object.keys(RTCRtpTransceiver.prototype).indexOf('currentDirection') > -1;
219
-        }
220
-
221 233
         return false;
222 234
     }
223 235
 

読み込み中…
キャンセル
保存