Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #353756 Score: 1
    Profile photo of Jurg van der Vlies
    Jurg van der Vlies
    Member
    beginner
    intermediate
    advanced
    curious george
    wise owl
    contributor
    2 pts
    @Jurg

    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?

    This post has received 1 vote up.
    #353764 Score: 1
    Profile photo of Joe Wieloch
    Joe Wieloch
    Moderator
    beginner
    intermediate
    friend finder
    contributor
    LUC16 Attendee
    verified member
    wise owl
    21 pts
    @wheels

    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!

     

     

     

     

    This post has received 1 vote up.
    #355201 Score: 0
    Profile photo of Jurg van der Vlies
    Jurg van der Vlies
    Member
    beginner
    intermediate
    advanced
    curious george
    wise owl
    contributor
    2 pts
    @Jurg

    Thanks, this works just fine!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.