Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use Jitsi Meet in an EmberJS app

In my Ember app I'm using ember-inject-script which I installed:

npm install --save-dev ember-inject-script

The controller.js file for my page looks like this:

import Ember from 'ember';
import injectScript from 'ember-inject-script';

export default Ember.Controller.extend({
  init: function() {
    this._super();
    var url = "https://meet.jit.si/external_api.js";
    injectScript(url);
    var domain = "meet.jit.si";
    var room = "JitsiMeetAPIExample";
    var width = 700;
    var height = 700;
    var htmlElement = document.querySelector('#meet');
    var api = new JitsiMeetExternalAPI(domain, room, width, height, 
              htmlElement);
  }
});

The Template is this:

<h2>Jitsi Meet</h2>
<div id="meet"></div>
{{outlet}}

Yet I get a console error:

Error while processing route: projects.index JitsiMeetExternalAPI is not defined ReferenceError: JitsiMeetExternalAPI is not defined

like image 523
mrlindsey Avatar asked Jul 13 '17 10:07

mrlindsey


People also ask

What is embed meeting in Jitsi meet?

Embedding the Jitsi Meet API into your site or app enables you to host and provide secure video meetings with your colleagues, teams, and stakeholders. The Meet API provides a full complement of comprehensive meeting features.

What is Lib Jitsi meet?

GitHub - jitsi/lib-jitsi-meet: A low-level JS video API that allows adding a completely custom video experience to web apps.

How do I integrate Jitsi into my website?

Well, here's what we believe is the easiest way in the world to do so: <script src='https://meet.jit.si/external_api.js'></script> ... const domain = 'meet.jit.si'; const options = { roomName: 'PickAnAppropriateMeetingNameHere', width: 700, height: 700, parentNode: document.


1 Answers

  • injectScript in asynchronous so you can't use JitsiMeetExternalAPI very next statement. You need to use then.

  • Another issue is, you are accessing the DOM element in controller init method, which will not be available. generally controller is not DOM aware. for this I will encourage you to write Component and use didInsertElement hook

One more alternative approach to load js at the required time, is in routes beforeModel hook, you can just use Ember.$.getJSON(url).

beforeModel(){
 return Ember.$.getJSON(url);
}
like image 174
Ember Freak Avatar answered Oct 18 '22 20:10

Ember Freak