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);
     }
