Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>New answer</strong></p> <p>The YouTube player object implements its own addEventListener method which is more like how AS3's syntax. As per the information listed <a href="http://code.google.com/apis/youtube/js_api_reference.html#Adding_event_listener" rel="nofollow noreferrer">here</a>: </p> <blockquote> <p>player.addEventListener(event:String, listener:String):Void</p> </blockquote> <p>YouTube provides an example on the page I linked which I'll provide here:</p> <pre><code>function onYouTubePlayerReady(playerId) { ytplayer = document.getElementById("myytplayer"); ytplayer.addEventListener("onStateChange", "onytplayerStateChange"); } function onytplayerStateChange(newState) { alert("Player's new state: " + newState); } </code></pre> <p>YouTube also provides an example page that seems to prove out that their example code works in IE. I'll link that example page <a href="http://code.google.com/apis/youtube/youtube_player_demo.html" rel="nofollow noreferrer">here</a>.</p> <p>Now, here's an attempt at re-writing the pertinent parts of your code to work as per the examples provided by Google/YouTube:</p> <pre><code>function onYouTubePlayerReady(playerId) { if(playerId &amp;&amp; playerId == 'ytvideo1'){ var ytplayer = document.getElementById('ytplayer1'); } else if(playerId &amp;&amp; playerId == 'ytvideo2'){ var ytplayer = document.getElementById("ytplayer2"); } else { return; } ytplayer.addEventListener('onStateChange', 'onytplayerStateChange'); } </code></pre> <p>So, it turns out that the mistake being made here arises from the confusion created by the use of the method name 'addEventListener'. In the W3C JavaScript implementation, the second parameter is a function while in the YouTube implementation, the second parameter is a string. Give this a shot =).</p>
    singulars
    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. 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