Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

Adds uiLoaded event in iframe API, fired when all resources are loaded.

damencho2478176f23cf
diff --git a/doc/api.md b/doc/api.md
index b811ab3eda..c5361e13d8 100644
--- a/doc/api.md
+++ b/doc/api.md
@@ -27,6 +27,7 @@ Its constructor gets a number of options:
* **interfaceConfigOverwrite**: (optional) JS object with overrides for options defined in [interface_config.js].
* **noSSL**: (optional, defaults to true) Boolean indicating if the server should be contacted using HTTP or HTTPS.
* **jwt**: (optional) [JWT](https://jwt.io/) token.
+ * **onload**: (optional) handler for the iframe onload event.
Example:
diff --git a/modules/API/external/external_api.js b/modules/API/external/external_api.js
index 9408effb20..33568d57d7 100644
--- a/modules/API/external/external_api.js
+++ b/modules/API/external/external_api.js
@@ -123,7 +123,8 @@ function parseArguments(args) {
configOverwrite,
interfaceConfigOverwrite,
noSSL,
- jwt
+ jwt,
+ onload
] = args;
return {
@@ -134,7 +135,8 @@ function parseArguments(args) {
configOverwrite,
interfaceConfigOverwrite,
noSSL,
- jwt
+ jwt,
+ onload
};
case 'object': // new arguments format
return args[0];
@@ -196,6 +198,8 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
* used.
* @param {string} [options.jwt] - The JWT token if needed by jitsi-meet for
* authentication.
+ * @param {string} [options.onload] - The onload function that will listen
+ * for iframe onload event.
*/
constructor(domain, ...args) {
super();
@@ -207,7 +211,8 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
configOverwrite = {},
interfaceConfigOverwrite = {},
noSSL = false,
- jwt = undefined
+ jwt = undefined,
+ onload = undefined
} = parseArguments(args);
this._parentNode = parentNode;
@@ -218,7 +223,7 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
noSSL,
roomName
});
- this._createIFrame(height, width);
+ this._createIFrame(height, width, onload);
this._transport = new Transport({
backend: new PostMessageTransportBackend({
postisOptions: {
@@ -243,11 +248,13 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
* parseSizeParam for format details.
* @param {number|string} width - The with of the iframe. Check
* parseSizeParam for format details.
+ * @param {Function} onload - The function that will listen
+ * for onload event.
* @returns {void}
*
* @private
*/
- _createIFrame(height, width) {
+ _createIFrame(height, width, onload) {
const frameName = `jitsiConferenceFrame${id}`;
this._frame = document.createElement('iframe');
@@ -258,6 +265,13 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
this._setSize(height, width);
this._frame.setAttribute('allowFullScreen', 'true');
this._frame.style.border = 0;
+
+ if (onload) {
+ // waits for iframe resources to load
+ // and fires event when it is done
+ this._frame.onload = onload;
+ }
+
this._frame = this._parentNode.appendChild(this._frame);
}