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-18 05:47:12 +08:00
|
|
|
|
|
|
|
function getConnObj() {
|
|
|
|
return swfobject.getObjectById("RTMPConnCheck");
|
|
|
|
}
|
2013-04-16 23:42:31 +08:00
|
|
|
|
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);
|
|
|
|
}
|
2013-04-17 05:17:00 +08:00
|
|
|
|
|
|
|
BBBCheck.showCamSettings = function() {
|
|
|
|
var swfObj = getSwfObj();
|
|
|
|
if (swfObj) {
|
|
|
|
swfObj.showCamSettings();
|
|
|
|
}
|
|
|
|
}
|
2013-04-16 23:42:31 +08:00
|
|
|
|
|
|
|
BBBCheck.showMicSettings = function() {
|
|
|
|
var swfObj = getSwfObj();
|
|
|
|
if (swfObj) {
|
|
|
|
swfObj.showMicSettings();
|
|
|
|
}
|
|
|
|
}
|
2013-04-17 05:17:00 +08:00
|
|
|
|
|
|
|
BBBCheck.startTestMicrophone = function() {
|
|
|
|
var swfObj = getSwfObj();
|
|
|
|
if (swfObj) {
|
|
|
|
swfObj.startTestMicrophone();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BBBCheck.stopTestMicrophone = function() {
|
|
|
|
var swfObj = getSwfObj();
|
|
|
|
if (swfObj) {
|
|
|
|
swfObj.stopTestMicrophone();
|
|
|
|
}
|
|
|
|
}
|
2013-04-16 23:42:31 +08:00
|
|
|
|
2013-04-18 05:47:12 +08:00
|
|
|
BBBCheck.testRTMPConnection = function(host, app) {
|
|
|
|
var swfObj = getConnObj();
|
|
|
|
if (swfObj) {
|
|
|
|
swfObj.testRTMPConnection(host, app);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BBBCheck.testSocketConnection = function(host, port) {
|
|
|
|
var swfObj = getConnObj();
|
|
|
|
if (swfObj) {
|
|
|
|
swfObj.testSocketConnection(host, port);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*** Callbacks from Flash test apps **/
|
2013-04-16 23:42:31 +08:00
|
|
|
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.");
|
|
|
|
}
|
2013-04-18 02:36:43 +08:00
|
|
|
|
|
|
|
BBBCheck.camAccessDenied = function() {
|
|
|
|
console.log("Cam access has been denied.");
|
|
|
|
}
|
|
|
|
|
|
|
|
BBBCheck.camAccessAllowed = function() {
|
|
|
|
console.log("Cam access has been allowed.");
|
|
|
|
}
|
2013-04-16 23:42:31 +08:00
|
|
|
|
2013-04-18 05:47:12 +08:00
|
|
|
BBBCheck.invalidParamsForRtmpConnectionTest = function() {
|
|
|
|
console.log("Invalid host or app for rtmp connection test.");
|
|
|
|
}
|
|
|
|
|
|
|
|
BBBCheck.rtmpConnectionTestSuccess = function(rtmp, server, application) {
|
|
|
|
console.log("Connection succeeded using rtmp[" + rtmp + "]");
|
|
|
|
}
|
|
|
|
|
|
|
|
BBBCheck.rtmpConnectionTestFailed = function(host, app) {
|
|
|
|
console.log("Failed to connect to [" + host + "][" + app + "]");
|
|
|
|
}
|
|
|
|
|
|
|
|
BBBCheck.socketConnTestFailed = function(host, port) {
|
|
|
|
console.log("Failed to connect to [" + host + "][" + port + "]");
|
|
|
|
}
|
|
|
|
|
|
|
|
BBBCheck.socketConnTestClosed = function(host, port) {
|
|
|
|
console.log("Connection closed to [" + host + "][" + port + "]");
|
|
|
|
}
|
|
|
|
|
|
|
|
BBBCheck.socketConnTestSuccess = function(host, port) {
|
|
|
|
console.log("Connection success to [" + host + "][" + port + "]");
|
|
|
|
}
|
|
|
|
|
|
|
|
BBBCheck.socketConnTestIOError = function(host, port) {
|
|
|
|
console.log("Connection IO error to [" + host + "][" + port + "]");
|
|
|
|
}
|
|
|
|
|
|
|
|
BBBCheck.socketConnTestSecurityError = function(host, port) {
|
|
|
|
console.log("Connection security error to [" + host + "][" + port + "]");
|
|
|
|
}
|
|
|
|
|
2013-04-16 23:42:31 +08:00
|
|
|
/* ***********************************************************************************
|
|
|
|
* 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);
|
|
|
|
|