How can we integrate the youtube iframe api in ember.js
1 Like
Put the youtube script loading code into an Ember initializer. Possibly you should use app.deferReadiness & advanceReadiness so that you wait for Youtube’s api to call you back and say it’s available.
Then make an Ember component that calls new YT.Player(...)
from its didInsertElement
hook, like:
// app/components/youtube-player.js
export default Ember.Component.extend({
didInsertElement: function(){
new YT.Player(this.get('element'), {videoId: this.get('videoId')});
}
})
Then just use {{youtube-player videoId="1234"}}
in your template.
Is there any way to create complete player using youtube iframe api without component