0

I am trying to make a chrome extension,and for that I need to control the flash player on the YouTube by injecting my script through content script I am able to play ,pause and stop the video but the event listener does not fire. this is my code:

function onYouTubePlayerReady(playerId) {
     currentVideo = document.getElementById("movie_player");
 window.onPlayerStateChange = function() {};
 currentVideo.addEventListener("onStateChange", function(e) {
    console.log('State is:', e.data);
});

}

EDIT: I found my mistake,apparently for flash function written inside the "addeventlistener" does not work.

     function onYouTubePlayerReady(playerId) {
         currentVideo = document.getElementById("movie_player");
     currentVideo.addEventListener("onStateChange", "StateChanged");
     }

     function StateChanged(e) {
         console.log('State is:', e);
     }
  • possible duplicate of [Building a Chrome Extension - Inject code in a page using a Content script](http://stackoverflow.com/questions/9515704/building-a-chrome-extension-inject-code-in-a-page-using-a-content-script) – jlmcdonald Feb 12 '14 at 07:33
  • i came across that earlier but it does not solve my problem, i wrote the above function in the injected script as the answer suggests. but still the onstatechange is not getting fired – srajanpali Feb 12 '14 at 12:01

0 Answers0