Time line scrubbing in Video object

Forums: 

Hi,
we need to control time line scrubbing by script.
Can we suggest me which API to use?


At the moment we able to read the player's current position in following way:

var iframeH5P = document.getElementsByClassName('h5p-iframe')[0].contentWindow.H5P;
var iframeVideo = iframeH5P.instances[0].video;
current = iframeVideo.getCurrentTime();

Thank you.

otacke's picture

Hi Scandy!

First of all, you should not use the DOM to get into iframe and from there to the H5P object and then "guessing" the first instance element - pages could host more than one. The clean was is to use the alter_scripts (see dev docs) hook to add scripts to H5P.InteractiveVideo instances directly. You can use the same frame as for CoursePresentation used at https://github.com/h5p/h5p-course-presentation/issues/111#issuecomment-615875442.

There's no documented API, but you will find the source code of video handlers at https://github.com/h5p/h5p-video/tree/master/scripts where you can see what functions are available and do what.

Best,
Oliver