Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm sorry mate. The solution to your problem is "easy" to code/implement but painful and difficult to maintain.</p> <p>Youtube API does not allow to embed a YT.Player object within an Iframe (e.g. div within an iframe), because it looks for the 'player' node within the window object and not in the iframe document.</p> <p>So, a quick hotfix for this would be to save a copy of the API files and modify them to add this functionality. Obviously, from that moment on, it is your responsability to serve these files and also to update them in order the files do not get deprecated.</p> <p>The solution would be (I take for granted JQuery is loaded before Youtube API):</p> <p>Using the base example provided at <a href="https://developers.google.com/youtube/iframe_api_reference#Getting_Started" rel="nofollow">https://developers.google.com/youtube/iframe_api_reference#Getting_Started</a> I guess you have this <code>&lt;iframe id="if"&gt;&lt;/iframe&gt;</code> instead of <code>&lt;div id="player"&gt;&lt;/div&gt;</code> and that later on you append the player div inside that iframe.</p> <pre><code>&lt;body&gt; &lt;iframe id="if"&gt;&lt;/iframe&gt; &lt;script&gt; $('#if').contents().find('body').append($('&lt;div id="player"&gt;&lt;/div&gt;')); // ... </code></pre> <p>So, whem defining <code>onYoutubeAPIReady()</code>, you must add 1 parameter to the <code>YT.Player</code> constructor:</p> <pre><code>function onYouTubeIframeAPIReady() { player = new YT.Player('player', { /* options */ }, $('#if') ); </code></pre> <p>That is <code>$('#if')</code>, the iframe element where you want to embed the player.</p> <p><strong>iframe_api</strong></p> <p>In this file you just need to modify the src of the script it loads: </p> <p>from <code>a.src = 'http://s.ytimg.com/yts/jsbin/www-widgetapi-vflOb0oo1.js</code></p> <p>to <code>a.src = './widget.js';</code> (widget.js is your copy of www-widgetapi-vflOb0oo1.js).</p> <p>Finally on widget.js:</p> <p>Here you must modify this 2 functions: <code>function S(a,b)</code> and <code>function Y(a,b)</code>.</p> <p>First <code>function Y(a,b)</code> to <code>function Y(a,b,c)</code> in order to get the iframe parameter. Then in its body you change <code>S.call(this,a,new nb(b));</code> to <code>S.call(this,a,new nb(b),c);</code></p> <p>Second, <code>function S(a,b)</code> to <code>function S(a,b, dom)</code> and <code>c = document</code> to <code>c= dom === undefined ? document : dom.contents()[0]</code>.</p> <p>Now you have a Youtube player inside your iframe and you are able to use it from the parent window.</p> <p>I hope it is useful! ;)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload