Working on a Chrome extension, injecting script to Youtube site itself, and listening to the player events using the Youtube player API.
Injected script code:
(you can run it in the console on a Youtube HTML5 video page and see that it works)
var theYTplayer = document.getElementById('movie_player');
theYTplayer.addEventListener('onStateChange', function(){
console.log('--- player state has been changed');
});
When it comes to HTML5 videos, it all works great, but not in flash live streams.
In Flash, for some reason all the GET functions returns errors, while the SET functions works good.
GET: getPlayerState
, isMuted
, getVolume
SET: playVideo
, pauseVideo
, mute
, unMute
, setVolume
This may be a bug, so I reported about it here: issue #7043
You can test it on this live streaming video for example.
If I'm doing something wrong then please let me know how it should be done.
In case and it is a bug, then lets think of another way to detect whether the video is playing or not.
I compared between the two DOMs and there is no any class being added when the state changes or anything else, the files ended to be match.
Then I saw that when the video is playing Chrome adds the new extra favicon speaker to the tab, but that's only if there is sound, if the video is muted then the icon will not appear so this is no good. so do you may have any other ideas/workarounds how to detect if the video is playing or not please or fixing my code?