backbone.js - BackboneJS How to load Youtube Iframe in view -


I have a backbone app where I have a view in which I want to display a YouTube player:

< P> Then in my view, after the reader - I did this:

  AfterRender: function () {var tag = document.createElement ('script') ; Tag src = "https://www.youtube.com/iframe_api"; Var firstScriptTag = document.getElementsByTagName ('script') [0]; FirstScriptTag.parentNode.insertBefore (tag, firstScriptTag); Var player; Function: {'On': OnPlayer Read, 'Onestate Change': '' On YouTube ';' Onplayerstate Change}}); }player read (event) on function {event.target.playVideo (); } Var done = false; Function on playerstate change (event) {if (event.data == YT.PlayerState.PLAYING & amp;!) {SetTimeout (stop video, 6000); Did = true; }} Stop the video (event) {player.stopVideo (); }}  

but it does not have any rendering but I can not even get errors and in my console I can see that the YouTube API is loaded ... then I What's wrong here?

Please help ..

See this related question:

< P> I think the problem is that your onYouTubeIframeAPIReady function needs to be declared globally, not nested inside any other function. (In your code, this is defined only within the scope of the Reader method.)


Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -