I want to implement jwplayer on an emberjs app, i use bower to install jwplayer and i include it on ember cli build.
app.import('bower_components/jwplayer/jwplayer.js');
The problem is when im trying on the application route to setup the jwplayer:
init() {
this._super(...arguments);
jwplayer.key='t7jmHu1/RAgJaW/NYESUcyMbUjuFcEeBqDTr/Q==';
jwplayer("video").setup({
file: "http://content.bitsontherun.com/videos/nhYDGoyh-kNspJqnJ.mp4"
});
}
Anyone knows how to fix this?
It's generally preferable to do this type of setup within a component. Doing so gives you much better control over when external plugins like this are loaded and unloaded.
See the discussion of third party libraries on this page (https://guides.emberjs.com/v2.7.0/components/the-component-lifecycle/) about halfway down the page. You'll also want to make sure you clean up use of your library in the
willDestroyElementhook so that you don't end up with multiple "ghost" versions of your library floating around in memory ...