Change current time video player

jurg
jurg Community Member Posts: 28
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?

Comments

  • wheels
    wheels Community Member, Administrator, Moderator, Rockstar Manager Posts: 528 eLearning ROCKSTAR Admin Team
    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!

     

     

     

     
  • jurg
    jurg Community Member Posts: 28
    Thanks, this works just fine!
Sign In or Register to comment.

So You Wanna Be An eLearning ROCKSTAR?

We're all fans of eLearning here! Want to become an eLearning ROCKSTAR? Just click on one of the buttons below to start your rocking journey!