浏览代码

Gets rid fo RTCBrowserType usages.

master
paweldomas 10 年前
父节点
当前提交
7ec6e9ae29

+ 0
- 171
modules/RTC/RTCBrowserType.js 查看文件

@@ -1,171 +0,0 @@
1
-
2
-var currentBrowser;
3
-
4
-var browserVersion;
5
-
6
-var isAndroid;
7
-
8
-var RTCBrowserType = {
9
-
10
-    RTC_BROWSER_CHROME: "rtc_browser.chrome",
11
-
12
-    RTC_BROWSER_OPERA: "rtc_browser.opera",
13
-
14
-    RTC_BROWSER_FIREFOX: "rtc_browser.firefox",
15
-
16
-    RTC_BROWSER_IEXPLORER: "rtc_browser.iexplorer",
17
-
18
-    RTC_BROWSER_SAFARI: "rtc_browser.safari",
19
-
20
-    getBrowserType: function () {
21
-        return currentBrowser;
22
-    },
23
-
24
-    isChrome: function () {
25
-        return currentBrowser === RTCBrowserType.RTC_BROWSER_CHROME;
26
-    },
27
-
28
-    isOpera: function () {
29
-        return currentBrowser === RTCBrowserType.RTC_BROWSER_OPERA;
30
-    },
31
-    isFirefox: function () {
32
-        return currentBrowser === RTCBrowserType.RTC_BROWSER_FIREFOX;
33
-    },
34
-
35
-    isIExplorer: function () {
36
-        return currentBrowser === RTCBrowserType.RTC_BROWSER_IEXPLORER;
37
-    },
38
-
39
-    isSafari: function () {
40
-        return currentBrowser === RTCBrowserType.RTC_BROWSER_SAFARI;
41
-    },
42
-    isTemasysPluginUsed: function () {
43
-        return RTCBrowserType.isIExplorer() || RTCBrowserType.isSafari();
44
-    },
45
-    getFirefoxVersion: function () {
46
-        return RTCBrowserType.isFirefox() ? browserVersion : null;
47
-    },
48
-
49
-    getChromeVersion: function () {
50
-        return RTCBrowserType.isChrome() ? browserVersion : null;
51
-    },
52
-
53
-    usesPlanB: function() {
54
-        return RTCBrowserType.isChrome() || RTCBrowserType.isOpera() ||
55
-            RTCBrowserType.isTemasysPluginUsed();
56
-    },
57
-
58
-    usesUnifiedPlan: function() {
59
-        return RTCBrowserType.isFirefox();
60
-    },
61
-
62
-    /**
63
-     * Whether the browser is running on an android device.
64
-     */
65
-    isAndroid: function() {
66
-        return isAndroid;
67
-    }
68
-
69
-    // Add version getters for other browsers when needed
70
-};
71
-
72
-// detectOpera() must be called before detectChrome() !!!
73
-// otherwise Opera wil be detected as Chrome
74
-function detectChrome() {
75
-    if (navigator.webkitGetUserMedia) {
76
-        currentBrowser = RTCBrowserType.RTC_BROWSER_CHROME;
77
-        var userAgent = navigator.userAgent.toLowerCase();
78
-        // We can assume that user agent is chrome, because it's
79
-        // enforced when 'ext' streaming method is set
80
-        var ver = parseInt(userAgent.match(/chrome\/(\d+)\./)[1], 10);
81
-        console.log("This appears to be Chrome, ver: " + ver);
82
-        return ver;
83
-    }
84
-    return null;
85
-}
86
-
87
-function detectOpera() {
88
-    var userAgent = navigator.userAgent;
89
-    if (userAgent.match(/Opera|OPR/)) {
90
-        currentBrowser = RTCBrowserType.RTC_BROWSER_OPERA;
91
-        var version = userAgent.match(/(Opera|OPR) ?\/?(\d+)\.?/)[2];
92
-        console.info("This appears to be Opera, ver: " + version);
93
-        return version;
94
-    }
95
-    return null;
96
-}
97
-
98
-function detectFirefox() {
99
-    if (navigator.mozGetUserMedia) {
100
-        currentBrowser = RTCBrowserType.RTC_BROWSER_FIREFOX;
101
-        var version = parseInt(
102
-            navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1], 10);
103
-        console.log('This appears to be Firefox, ver: ' + version);
104
-        return version;
105
-    }
106
-    return null;
107
-}
108
-
109
-function detectSafari() {
110
-    if ((/^((?!chrome).)*safari/i.test(navigator.userAgent))) {
111
-        currentBrowser = RTCBrowserType.RTC_BROWSER_SAFARI;
112
-        console.info("This appears to be Safari");
113
-        // FIXME detect Safari version when needed
114
-        return 1;
115
-    }
116
-    return null;
117
-}
118
-
119
-function detectIE() {
120
-    var version;
121
-    var ua = window.navigator.userAgent;
122
-
123
-    var msie = ua.indexOf('MSIE ');
124
-    if (msie > 0) {
125
-        // IE 10 or older => return version number
126
-        version = parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);
127
-    }
128
-
129
-    var trident = ua.indexOf('Trident/');
130
-    if (!version && trident > 0) {
131
-        // IE 11 => return version number
132
-        var rv = ua.indexOf('rv:');
133
-        version = parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);
134
-    }
135
-
136
-    var edge = ua.indexOf('Edge/');
137
-    if (!version && edge > 0) {
138
-        // IE 12 => return version number
139
-        version = parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);
140
-    }
141
-
142
-    if (version) {
143
-        currentBrowser = RTCBrowserType.RTC_BROWSER_IEXPLORER;
144
-        console.info("This appears to be IExplorer, ver: " + version);
145
-    }
146
-    return version;
147
-}
148
-
149
-function detectBrowser() {
150
-    var version;
151
-    var detectors = [
152
-        detectOpera,
153
-        detectChrome,
154
-        detectFirefox,
155
-        detectIE,
156
-        detectSafari
157
-    ];
158
-    // Try all browser detectors
159
-    for (var i = 0; i < detectors.length; i++) {
160
-        version = detectors[i]();
161
-        if (version)
162
-            return version;
163
-    }
164
-    console.error("Failed to detect browser type");
165
-    return undefined;
166
-}
167
-
168
-browserVersion = detectBrowser();
169
-isAndroid = navigator.userAgent.indexOf('Android') != -1;
170
-
171
-module.exports = RTCBrowserType;

+ 0
- 6
modules/UI/videolayout/LargeVideo.js 查看文件

@@ -8,8 +8,6 @@ import BottomToolbar from '../toolbars/BottomToolbar';
8 8
 import Avatar from "../avatar/Avatar";
9 9
 import {createDeferred} from '../../util/helpers';
10 10
 
11
-const RTCBrowserType = require("../../RTC/RTCBrowserType");
12
-
13 11
 const avatarSize = interfaceConfig.DOMINANT_SPEAKER_AVATAR_SIZE;
14 12
 const FADE_DURATION_MS = 300;
15 13
 
@@ -175,10 +173,6 @@ class VideoContainer extends LargeContainer {
175 173
         this.$avatar = $('#dominantSpeaker');
176 174
         this.$wrapper = $('#largeVideoWrapper');
177 175
 
178
-        if (!RTCBrowserType.isIExplorer()) {
179
-            this.$video.volume = 0;
180
-        }
181
-
182 176
         // This does not work with Temasys plugin - has to be a property to be
183 177
         // copied between new <object> elements
184 178
         //this.$video.on('play', onPlay);

+ 4
- 5
modules/UI/videolayout/LocalVideo.js 查看文件

@@ -5,8 +5,8 @@ import UIEvents from "../../../service/UI/UIEvents";
5 5
 import SmallVideo from "./SmallVideo";
6 6
 
7 7
 var LargeVideo = require("./LargeVideo");
8
-var RTCBrowserType = require("../../RTC/RTCBrowserType");
9 8
 
9
+const RTCUIUtils = JitsiMeetJS.util.RTCUIHelper;
10 10
 const TrackEvents = JitsiMeetJS.events.track;
11 11
 
12 12
 function LocalVideo(VideoLayout, emitter) {
@@ -166,10 +166,9 @@ LocalVideo.prototype.changeVideo = function (stream) {
166 166
     this.flipX = stream.videoType != "desktop";
167 167
     let localVideo = document.createElement('video');
168 168
     localVideo.id = 'localVideo_' + stream.getId();
169
-    if (!RTCBrowserType.isIExplorer()) {
170
-        localVideo.autoplay = true;
171
-        localVideo.volume = 0; // is it required if audio is separated ?
172
-    }
169
+
170
+    RTCUIUtils.setAutoPlay(localVideo, true);
171
+    RTCUIUtils.setVolume(localVideo, 0);
173 172
 
174 173
     var localVideoContainer = document.getElementById('localVideoWrapper');
175 174
     // Put the new video always in front

+ 3
- 5
modules/UI/videolayout/RemoteVideo.js 查看文件

@@ -7,8 +7,6 @@ import AudioLevels from "../audio_levels/AudioLevels";
7 7
 import UIUtils from "../util/UIUtil";
8 8
 import UIEvents from '../../../service/UI/UIEvents';
9 9
 
10
-var RTCBrowserType = require("../../RTC/RTCBrowserType");
11
-
12 10
 function RemoteVideo(id, VideoLayout, emitter) {
13 11
     this.id = id;
14 12
     this.emitter = emitter;
@@ -251,9 +249,9 @@ RemoteVideo.prototype.addRemoteStreamElement = function (stream) {
251 249
 
252 250
     // If we hide element when Temasys plugin is used then
253 251
     // we'll never receive 'onplay' event and other logic won't work as expected
254
-    if (!RTCBrowserType.isTemasysPluginUsed()) {
255
-        $(streamElement).hide();
256
-    }
252
+    // NOTE: hiding will not have effect when Temasys plugin is in use, as
253
+    // calling attach will show it back
254
+    $(streamElement).hide();
257 255
 
258 256
     // If the container is currently visible we attach the stream to the element.
259 257
     if (!isVideo || (this.container.offsetParent !== null && isVideo)) {

+ 1
- 5
modules/UI/videolayout/SmallVideo.js 查看文件

@@ -3,8 +3,6 @@
3 3
 import Avatar from "../avatar/Avatar";
4 4
 import UIUtil from "../util/UIUtil";
5 5
 
6
-var RTCBrowserType = require("../../RTC/RTCBrowserType");
7
-
8 6
 const RTCUIHelper = JitsiMeetJS.util.RTCUIHelper;
9 7
 
10 8
 function SmallVideo() {
@@ -129,9 +127,7 @@ SmallVideo.createStreamElement = function (stream) {
129 127
         element.setAttribute("muted", "true");
130 128
     }
131 129
 
132
-    if (!RTCBrowserType.isIExplorer()) {
133
-        element.autoplay = true;
134
-    }
130
+    RTCUIHelper.setAutoPlay(element, true);
135 131
 
136 132
     element.id = (isVideo ? 'remoteVideo_' : 'remoteAudio_') + stream.getId();
137 133
 

+ 6
- 18
modules/UI/videolayout/VideoLayout.js 查看文件

@@ -13,7 +13,7 @@ import LargeVideoManager, {VideoContainerType} from "./LargeVideo";
13 13
 import {PreziContainerType} from '../prezi/Prezi';
14 14
 import LocalVideo from "./LocalVideo";
15 15
 
16
-var RTCBrowserType = require('../../RTC/RTCBrowserType');
16
+const RTCUIUtil = JitsiMeetJS.util.RTCUIHelper;
17 17
 
18 18
 var remoteVideos = {};
19 19
 var remoteVideoTypes = {};
@@ -127,22 +127,18 @@ var VideoLayout = {
127 127
         let localAudio = document.getElementById('localAudio');
128 128
         localAudio = stream.attach(localAudio);
129 129
 
130
-        //return; // FIXME maybe move this into the library?
131
-        // Writing volume not allowed in IE
132
-        if (!RTCBrowserType.isIExplorer()) {
133
-            localAudio.autoplay = true;
134
-            localAudio.volume = 0;
135
-        }
136 130
         // Now when Temasys plugin is converting also <audio> elements to
137 131
         // plugin's <object>s, in current layout it will capture click events
138 132
         // before it reaches the local video object. We hide it here in order
139 133
         // to prevent that.
140
-        if (RTCBrowserType.isIExplorer()) {
134
+        //if (RTCBrowserType.isIExplorer()) {
141 135
             // The issue is not present on Safari. Also if we hide it in Safari
142 136
             // then the local audio track will have 'enabled' flag set to false
143 137
             // which will result in audio mute issues
144
-            $(localAudio).hide();
145
-        }
138
+            //  $(localAudio).hide();
139
+            localAudio.width = 1;
140
+            localAudio.height = 1;
141
+        //}
146 142
     },
147 143
 
148 144
     changeLocalVideo (stream) {
@@ -325,14 +321,6 @@ var VideoLayout = {
325 321
         }
326 322
 
327 323
         this.updateLargeVideo(resourceJid);
328
-
329
-        // Writing volume not allowed in IE
330
-        if (!RTCBrowserType.isIExplorer()) {
331
-            $('audio').each(function (idx, el) {
332
-                el.volume = 0;
333
-                el.volume = 1;
334
-            });
335
-        }
336 324
     },
337 325
 
338 326
 

正在加载...
取消
保存