I would like to receive events and get player options from a YouTube HTML5 player that is loaded when you browse to a video page on youtube.com.
I know can control the player via the HTML5 media events. For example, when I run this code in the console, it prints seeked
to the console whenever a seek event is triggered:
var v = document.getElementsByTagName("video")[0];
v.addEventListener("seeked", function() { console.log("seeked") }, true);
However, the YouTube player offers more in its API, for example various events that I want to subscribe to. How do I do that? Those events apparently are not fired on the video
element.
For example, how can I print something on the console when the onPlaybackQualityChange
event is fired?
Note: I am not talking about attaching to a player loaded via the iFrame API.