Javascript - Listen to YouTube player events in interactive video?

Hi!

I'd like to listen to the YouTube player events ('onReady', 'onStateChange') on a page with javascript, when a YouTube video is used in the Interactive video H5P content type in WordPress. How can I do that? Thanks in advance!

Content types: 
otacke's picture

Hi https://h5p.org/user/109552!

You can add your own scripts using the alter scripts hook (see customization docs at https://h5p.org/node/2692). Then you can wait for the content to be loaded, access the H5P content type instance and retrieve the video object to listen to, similar to https://h5p.org/comment/22925#comment-22925

Best,

Oliver