bigbluebutton-Github/bigbluebutton-client/resources/prod/check/lib/bbb_check.js

126 lines
3.6 KiB
JavaScript
Raw Normal View History

2013-04-12 17:36:21 +08:00
(function(window, undefined) {
var BBBCheck = {};
2013-04-16 23:42:31 +08:00
/**
* Internal function to get the BBB embed object. Seems like we have to do this
* each time and can't create a var for it.
*
* To get the object, see https://code.google.com/p/swfobject/wiki/api
*/
function getSwfObj() {
return swfobject.getObjectById("MicrophoneCheck");
}
2013-04-12 17:36:21 +08:00
BBBCheck.getFlashPlayerVersion = function() {
return swfobject.getFlashPlayerVersion();
}
BBBCheck.hasMinFlashPlayerVersion = function(flashVersion) {
return swfobject.hasFlashPlayerVersion(flashVersion);
}
2013-04-12 18:08:48 +08:00
BBBCheck.getBrowser = function() {
return deployJava.getBrowser();
}
BBBCheck.getJREs = function() {
return deployJava.getJREs();
}
BBBCheck.installJRE = function(version) {
deployJava.installJRE(version);
}
BBBCheck.installLatestJRE = function() {
deployJava.installLatestJRE();
}
2013-04-12 17:36:21 +08:00
2013-04-12 18:08:48 +08:00
BBBCheck.runApplet = function(attributes, parameters, minimumVersion) {
deployJava.runApplet(attributes, parameters, minimumVersion);
}
2013-04-12 17:36:21 +08:00
2013-04-16 23:42:31 +08:00
BBBCheck.runApplet = function(attributes, parameters, minimumVersion) {
deployJava.runApplet(attributes, parameters, minimumVersion);
}
BBBCheck.showMicSettings = function() {
var swfObj = getSwfObj();
if (swfObj) {
swfObj.showMicSettings();
}
}
BBBCheck.microphoneCheckAppReady = function() {
console.log("microphone check app ready.");
broadcast("MicCheckAppReadyEvent");
}
BBBCheck.noAvailableMicrophoneError = function() {
console.log("no available microphone");
}
BBBCheck.microphoneAccessDenied = function() {
console.log("Mic access has been denied.");
}
BBBCheck.microphoneAccessAllowed = function() {
console.log("Mic access has been allowed.");
}
/* ***********************************************************************************
* Broadcasting of events to 3rd-party apps.
*************************************************************************************/
/** Stores the 3rd-party app event listeners ***/
var listeners = {};
/**
* 3rd-party apps should user this method to register to listen for events.
*/
BBBCheck.listen = function(eventName, handler) {
if (typeof listeners[eventName] === 'undefined')
listeners[eventName] = [];
listeners[eventName].push(handler);
};
/**
* 3rd-party app should use this method to unregister listener for a given event.
*/
BBBCheck.unlisten = function(eventName, handler) {
if (!listeners[eventName])
return;
for (var i = 0; i < listeners[eventName].length; i++) {
if (listeners[eventName][i] === handler) {
listeners.splice(i, 1);
break;
}
}
};
/**
* Private function to broadcast received event from the BigBlueButton Flash client to
* 3rd-parties.
*/
function broadcast(eventName, params) {
if (!listeners[eventName]) {
console.log("No listeners for [" + eventName + "]");
return;
}
for (var i = 0; i < listeners[eventName].length; i++) {
console.log("Notifying listeners for [" + eventName + "]");
if (params == null) {
listeners[eventName][i]();
} else {
listeners[eventName][i](params);
}
}
};
2013-04-12 17:36:21 +08:00
window.BBBCheck = BBBCheck;
})(this);