Change current time video player
April 21, 2017 12:00 AM
Hi, I want to change the current time of the video player by executing Javascript. I have added an action to a button that executes Javascript. It runs:
var vid = document.getElementById("video10"); vid.currentTime = 5;
But the video player does not skip to 00:05.00. It doesn't work at all.
Is there anyone that can help me out?
Discussion (2)
I see you know the html name of the video object (which can be found in the properties tab of the video object by hovering over the popup "more" button in the audio panel under edit events).
It's easy in Lectora Online you would just use the html name to reference the object and call a JavaScript method:
video10.setTrackTime(5);
You can also retrieve the current time:
VarMyLectoraVariable.set(video10.getTrackTime());
One thing I like to do in my scripting is to set an additional variable dynamically so I can reuse the scripting in other titles. So I would point to my video object with a known variable.
Add an action to your video object, trigger On Page Show, action Run JavaScript:
window.MyMainVideo = %HTMLNAME%;
Now when calling APIs on that video object I can use my known reference, and this makes my scripts portable if I copy the video and scripting to another title.
For example: MyMainVideo.setTrackTime(5); will always resolve to the correct html name for the associated video!
undefined
Discussions have been disabled for this post