Gets rid fo RTCBrowserType usages.

This commit is contained in:
paweldomas 2016-02-02 15:50:02 -06:00
parent 522ca64bce
commit 7ec6e9ae29
6 changed files with 14 additions and 210 deletions

View File

@ -1,171 +0,0 @@
var currentBrowser;
var browserVersion;
var isAndroid;
var RTCBrowserType = {
RTC_BROWSER_CHROME: "rtc_browser.chrome",
RTC_BROWSER_OPERA: "rtc_browser.opera",
RTC_BROWSER_FIREFOX: "rtc_browser.firefox",
RTC_BROWSER_IEXPLORER: "rtc_browser.iexplorer",
RTC_BROWSER_SAFARI: "rtc_browser.safari",
getBrowserType: function () {
return currentBrowser;
},
isChrome: function () {
return currentBrowser === RTCBrowserType.RTC_BROWSER_CHROME;
},
isOpera: function () {
return currentBrowser === RTCBrowserType.RTC_BROWSER_OPERA;
},
isFirefox: function () {
return currentBrowser === RTCBrowserType.RTC_BROWSER_FIREFOX;
},
isIExplorer: function () {
return currentBrowser === RTCBrowserType.RTC_BROWSER_IEXPLORER;
},
isSafari: function () {
return currentBrowser === RTCBrowserType.RTC_BROWSER_SAFARI;
},
isTemasysPluginUsed: function () {
return RTCBrowserType.isIExplorer() || RTCBrowserType.isSafari();
},
getFirefoxVersion: function () {
return RTCBrowserType.isFirefox() ? browserVersion : null;
},
getChromeVersion: function () {
return RTCBrowserType.isChrome() ? browserVersion : null;
},
usesPlanB: function() {
return RTCBrowserType.isChrome() || RTCBrowserType.isOpera() ||
RTCBrowserType.isTemasysPluginUsed();
},
usesUnifiedPlan: function() {
return RTCBrowserType.isFirefox();
},
/**
* Whether the browser is running on an android device.
*/
isAndroid: function() {
return isAndroid;
}
// Add version getters for other browsers when needed
};
// detectOpera() must be called before detectChrome() !!!
// otherwise Opera wil be detected as Chrome
function detectChrome() {
if (navigator.webkitGetUserMedia) {
currentBrowser = RTCBrowserType.RTC_BROWSER_CHROME;
var userAgent = navigator.userAgent.toLowerCase();
// We can assume that user agent is chrome, because it's
// enforced when 'ext' streaming method is set
var ver = parseInt(userAgent.match(/chrome\/(\d+)\./)[1], 10);
console.log("This appears to be Chrome, ver: " + ver);
return ver;
}
return null;
}
function detectOpera() {
var userAgent = navigator.userAgent;
if (userAgent.match(/Opera|OPR/)) {
currentBrowser = RTCBrowserType.RTC_BROWSER_OPERA;
var version = userAgent.match(/(Opera|OPR) ?\/?(\d+)\.?/)[2];
console.info("This appears to be Opera, ver: " + version);
return version;
}
return null;
}
function detectFirefox() {
if (navigator.mozGetUserMedia) {
currentBrowser = RTCBrowserType.RTC_BROWSER_FIREFOX;
var version = parseInt(
navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1], 10);
console.log('This appears to be Firefox, ver: ' + version);
return version;
}
return null;
}
function detectSafari() {
if ((/^((?!chrome).)*safari/i.test(navigator.userAgent))) {
currentBrowser = RTCBrowserType.RTC_BROWSER_SAFARI;
console.info("This appears to be Safari");
// FIXME detect Safari version when needed
return 1;
}
return null;
}
function detectIE() {
var version;
var ua = window.navigator.userAgent;
var msie = ua.indexOf('MSIE ');
if (msie > 0) {
// IE 10 or older => return version number
version = parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);
}
var trident = ua.indexOf('Trident/');
if (!version && trident > 0) {
// IE 11 => return version number
var rv = ua.indexOf('rv:');
version = parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);
}
var edge = ua.indexOf('Edge/');
if (!version && edge > 0) {
// IE 12 => return version number
version = parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);
}
if (version) {
currentBrowser = RTCBrowserType.RTC_BROWSER_IEXPLORER;
console.info("This appears to be IExplorer, ver: " + version);
}
return version;
}
function detectBrowser() {
var version;
var detectors = [
detectOpera,
detectChrome,
detectFirefox,
detectIE,
detectSafari
];
// Try all browser detectors
for (var i = 0; i < detectors.length; i++) {
version = detectors[i]();
if (version)
return version;
}
console.error("Failed to detect browser type");
return undefined;
}
browserVersion = detectBrowser();
isAndroid = navigator.userAgent.indexOf('Android') != -1;
module.exports = RTCBrowserType;

View File

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

View File

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

View File

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

View File

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

View File

@ -13,7 +13,7 @@ import LargeVideoManager, {VideoContainerType} from "./LargeVideo";
import {PreziContainerType} from '../prezi/Prezi';
import LocalVideo from "./LocalVideo";
var RTCBrowserType = require('../../RTC/RTCBrowserType');
const RTCUIUtil = JitsiMeetJS.util.RTCUIHelper;
var remoteVideos = {};
var remoteVideoTypes = {};
@ -127,22 +127,18 @@ var VideoLayout = {
let localAudio = document.getElementById('localAudio');
localAudio = stream.attach(localAudio);
//return; // FIXME maybe move this into the library?
// Writing volume not allowed in IE
if (!RTCBrowserType.isIExplorer()) {
localAudio.autoplay = true;
localAudio.volume = 0;
}
// Now when Temasys plugin is converting also <audio> elements to
// plugin's <object>s, in current layout it will capture click events
// before it reaches the local video object. We hide it here in order
// to prevent that.
if (RTCBrowserType.isIExplorer()) {
//if (RTCBrowserType.isIExplorer()) {
// The issue is not present on Safari. Also if we hide it in Safari
// then the local audio track will have 'enabled' flag set to false
// which will result in audio mute issues
$(localAudio).hide();
}
// $(localAudio).hide();
localAudio.width = 1;
localAudio.height = 1;
//}
},
changeLocalVideo (stream) {
@ -325,14 +321,6 @@ var VideoLayout = {
}
this.updateLargeVideo(resourceJid);
// Writing volume not allowed in IE
if (!RTCBrowserType.isIExplorer()) {
$('audio').each(function (idx, el) {
el.volume = 0;
el.volume = 1;
});
}
},