Просмотр исходного кода

Expose JitsiMeetJS.environment with methods for environment detection

dev1
tsareg 9 лет назад
Родитель
Сommit
4b28402045
3 измененных файлов: 77 добавлений и 4 удалений
  1. 5
    4
      JitsiMeetJS.js
  2. 22
    0
      doc/API.md
  3. 50
    0
      modules/RTC/RTCBrowserType.js

+ 5
- 4
JitsiMeetJS.js Просмотреть файл

@@ -18,6 +18,7 @@ var Statistics = require("./modules/statistics/statistics");
18 18
 var Resolutions = require("./service/RTC/Resolutions");
19 19
 var ScriptUtil = require("./modules/util/ScriptUtil");
20 20
 var GlobalOnErrorHandler = require("./modules/util/GlobalOnErrorHandler");
21
+var RTCBrowserType = require("./modules/RTC/RTCBrowserType");
21 22
 
22 23
 function getLowerResolution(resolution) {
23 24
     if(!Resolutions[resolution])
@@ -42,6 +43,9 @@ var LibJitsiMeet = {
42 43
 
43 44
     version: '{#COMMIT_HASH#}',
44 45
 
46
+    // expose JitsiTrackError this way to give library consumers to do checks
47
+    // like if (error instanceof JitsiMeetJS.JitsiTrackError) { }
48
+    JitsiTrackError: JitsiTrackError,
45 49
     JitsiConnection: JitsiConnection,
46 50
     events: {
47 51
         conference: JitsiConferenceEvents,
@@ -57,6 +61,7 @@ var LibJitsiMeet = {
57 61
     },
58 62
     logLevels: Logger.levels,
59 63
     mediaDevices: JitsiMediaDevices,
64
+    environment: RTCBrowserType,
60 65
     init: function (options) {
61 66
         Statistics.audioLevelsEnabled = !options.disableAudioLevels;
62 67
 
@@ -202,10 +207,6 @@ var LibJitsiMeet = {
202 207
     }
203 208
 };
204 209
 
205
-// expose JitsiTrackError this way to give library consumers to do checks like
206
-// if (error instanceof JitsiMeetJS.JitsiTrackError) { }
207
-LibJitsiMeet.JitsiTrackError = JitsiTrackError;
208
-
209 210
 //Setups the promise object.
210 211
 window.Promise = window.Promise || require("es6-promise").Promise;
211 212
 

+ 22
- 0
doc/API.md Просмотреть файл

@@ -53,6 +53,8 @@ The ```options``` parameter is JS object with the following properties:
53 53
 
54 54
 * ```JitsiMeetJS.JitsiConnection``` - the ```JitsiConnection``` constructor. You can use that to create new server connection.
55 55
 
56
+* ```JitsiMeetJS.JitsiTrackError``` - the ```JitsiTrackError``` constructor. You can use that to check ```instanceof``` errors you get from ```JitsiMeetJS.createLocalTracks()``` method.
57
+
56 58
 * ```JitsiMeetJS.setLogLevel``` - changes the log level for the library. For example to have only error messages you should do:
57 59
 ```
58 60
 JitsiMeetJS.setLogLevel(JitsiMeetJS.logLevels.ERROR);
@@ -88,6 +90,26 @@ JitsiMeetJS.setLogLevel(JitsiMeetJS.logLevels.ERROR);
88 90
     - ```addEventListener(event, handler)``` - attaches an event handler.
89 91
     - ```removeEventListener(event, handler)``` - removes an event handler.
90 92
 
93
+* ```JitsiMeetJS.environment``` - environment detection helper. Provides following methods and properties:
94
+    - ```RTC_BROWSER_CHROME```
95
+    - ```RTC_BROWSER_OPERA```
96
+    - ```RTC_BROWSER_FIREFOX```
97
+    - ```RTC_BROWSER_IEXPLORER```
98
+    - ```RTC_BROWSER_SAFARI```
99
+    - ```RTC_BROWSER_NWJS```
100
+    - ```RTC_BROWSER_REACT_NATIVE```
101
+    - ```getBrowserType()``` - gets current browser type.
102
+    - ```isChrome()``` - checks if current browser is Chrome.
103
+    - ```isOpera()``` - checks if current browser is Opera.
104
+    - ```isFirefox()``` - checks if current browser is Firefox.
105
+    - ```isIExplorer()``` - checks if current browser is Internet Explorer.
106
+    - ```isSafari()``` - checks if current browser is Safari.
107
+    - ```isNWJS()``` - checks if current environment is NWJS.
108
+    - ```isReactNative()``` - checks if current environment is React Native.
109
+    - ```isTemasysPluginUsed()``` - checks if Temasys RTC plugin is used.
110
+    - ```getFirefoxVersion()``` - returns Firefox version.
111
+    - ```getChromeVersion()``` - returns Chrome version.
112
+    - ```isAndroid()``` - checks whether the browser is running on an android device.
91 113
 
92 114
 * ```JitsiMeetJS.events``` - JS object that contains all events used by the API. You will need that JS object when you try to subscribe for connection or conference events.
93 115
     We have two event types - connection and conference. You can access the events with the following code ```JitsiMeetJS.events.<event_type>.<event_name>```.

+ 50
- 0
modules/RTC/RTCBrowserType.js Просмотреть файл

@@ -22,41 +22,90 @@ var RTCBrowserType = {
22 22
 
23 23
     RTC_BROWSER_REACT_NATIVE: "rtc_browser.react-native",
24 24
 
25
+    /**
26
+     * Gets current browser type.
27
+     * @returns {string}
28
+     */
25 29
     getBrowserType: function () {
26 30
         return currentBrowser;
27 31
     },
28 32
 
33
+    /**
34
+     * Checks if current browser is Chrome.
35
+     * @returns {boolean}
36
+     */
29 37
     isChrome: function () {
30 38
         return currentBrowser === RTCBrowserType.RTC_BROWSER_CHROME;
31 39
     },
32 40
 
41
+    /**
42
+     * Checks if current browser is Opera.
43
+     * @returns {boolean}
44
+     */
33 45
     isOpera: function () {
34 46
         return currentBrowser === RTCBrowserType.RTC_BROWSER_OPERA;
35 47
     },
48
+
49
+    /**
50
+     * Checks if current browser is Firefox.
51
+     * @returns {boolean}
52
+     */
36 53
     isFirefox: function () {
37 54
         return currentBrowser === RTCBrowserType.RTC_BROWSER_FIREFOX;
38 55
     },
39 56
 
57
+    /**
58
+     * Checks if current browser is Internet Explorer.
59
+     * @returns {boolean}
60
+     */
40 61
     isIExplorer: function () {
41 62
         return currentBrowser === RTCBrowserType.RTC_BROWSER_IEXPLORER;
42 63
     },
43 64
 
65
+    /**
66
+     * Checks if current browser is Safari.
67
+     * @returns {boolean}
68
+     */
44 69
     isSafari: function () {
45 70
         return currentBrowser === RTCBrowserType.RTC_BROWSER_SAFARI;
46 71
     },
72
+
73
+    /**
74
+     * Checks if current environment is NWJS.
75
+     * @returns {boolean}
76
+     */
47 77
     isNWJS: function () {
48 78
         return currentBrowser === RTCBrowserType.RTC_BROWSER_NWJS;
49 79
     },
80
+
81
+    /**
82
+     * Checks if current environment is React Native.
83
+     * @returns {boolean}
84
+     */
50 85
     isReactNative: function () {
51 86
         return currentBrowser === RTCBrowserType.RTC_BROWSER_REACT_NATIVE;
52 87
     },
88
+
89
+    /**
90
+     * Checks if Temasys RTC plugin is used.
91
+     * @returns {boolean}
92
+     */
53 93
     isTemasysPluginUsed: function () {
54 94
         return RTCBrowserType.isIExplorer() || RTCBrowserType.isSafari();
55 95
     },
96
+
97
+    /**
98
+     * Returns Firefox version.
99
+     * @returns {number|null}
100
+     */
56 101
     getFirefoxVersion: function () {
57 102
         return RTCBrowserType.isFirefox() ? browserVersion : null;
58 103
     },
59 104
 
105
+    /**
106
+     * Returns Chrome version.
107
+     * @returns {number|null}
108
+     */
60 109
     getChromeVersion: function () {
61 110
         return RTCBrowserType.isChrome() ? browserVersion : null;
62 111
     },
@@ -72,6 +121,7 @@ var RTCBrowserType = {
72 121
 
73 122
     /**
74 123
      * Whether the browser is running on an android device.
124
+     * @returns {boolean}
75 125
      */
76 126
     isAndroid: function() {
77 127
         return isAndroid;

Загрузка…
Отмена
Сохранить