Get currentTime (Javascript) for audio or video file on a SL slide

Jun 24, 2015

Hi, I'm trying the solve the issue of keeping audio or video in sync with other timed object during a slide playback. I know/have tried all the sync'ing techniques using standard Storyline 2 features but in reality things always go out of sync during playback as the audio or video file gets delayed.  Flash is Ok but the html5 output doesn't stay sync'd for long.

I have a technique I use with other more 'hand crafted' authoring tools where I use a Javascript Timer function to read the 'Current Time' of the clip every 10th second and update a variable with that current time. The variable can then in turn trigger text or image objects etc based on its current value. If the audio/video gets delayed the other objects are also delayed.

I would like to try the same technique inside Storyline however for the Javascript to read the Current Time I need the put the correct path format within the Javascript to directly address the audio or video clip on the slide.

Does anyone know if there is a way to describe the path to an audio/video clip on a SL slide within Javascript code.

 

 

 

 

 

18 Replies
Mike B.

Trevor,

I'm not sure how this might be accomplished with a video that's actually "in" the project, but you might be able to pull this off with a video embedded from a website. The Wistia streaming service has a javascript API that will report the current position in the video. Check out the docs here: http://wistia.com/doc/player-api

They have a 2-week trial if you want to test this out. Vimeo may have a similar function.

Please let me know if you get this working, as I'm using Wistia and trying to change a SL2 variable when the video finishes playing, so I can auto-advance to the next slide. I've gotten it to throw up a JS alert, but can't get it to change the SL2 variable for me.

Thanks,

Mike

Trevor White-Miller

Hi Mike, thanks for the information regarding Wistia. I didn't really want to make the media files external however looking at the Wistia service it looks a professional setup and pricing is OK. The JavaScript API looks to have the elements I require for getting the actual time from the video if I can then link it with a SL variable. Apart from the coding I first need to see how playback performs from a linked video in my client's environment and also fully test out the flash/html5 output in Storyline matched with the flash/html5 output  from Wistia. If I can get it to work it will deal with my closed captions solution.

If I get it working I'll let you know and let you have the solution.

Accurate sync'ing with an audio voice over is my main issue. This is by far the biggest volume compared to the odd video clip now and then. So I'll have to keep looking for a solution.

Trevor White-Miller

Hi Mike, have been looking at the Wistia API this morning. Their API examples are working great in html pages outside of Storyline i.e. I'm loading a web object inside a SL2 slide which links out to my html holding the video embed code and the API JavaScript function. But I can't get anything to work by placing the JavaScript directly in a SL2 trigger.

The Alert example you spoke about, is that JavaScript sitting inside a SL2 trigger? If so can you share the .story.file so I can see your code.

Mike B.

I've placed their JS code inside of the video embed, and it does throw up the alert from there, but I'm unable as of yet to get it to set a SL variable from there. I'm hopefully going to get some help on that this weekend, and will find out whether or not it can even be done.

Here's all the code I have embedded using "Insert Video from Website". I've replaced the string for my video with "CodeForVideo" so place yours in there to make it work. I know JS is not "supported" by Staff here, but this is where it would really be helpful to know how SL builds out the course, to determine why some JS does not work as expected.

<script src="http://fast.wistia.net/assets/external/E-v1.js"></script>
<iframe src="http://fast.wistia.net/embed/iframe/CodeForVideo" allowtransparency="true" frameborder="0" scrolling="no" class="wistia_embed" name="wistia_embed" allowfullscreen="" mozallowfullscreen="" webkitallowfullscreen="" oallowfullscreen="" msallowfullscreen="" width="640" height="360"></iframe>

<script type="text/javascript">
wistiaEmbeds.onFind(function(video) {
video.bind("end", function() {
alert("I am an alert box!");
return this.unbind;
});
});
</script>

 

Trevor White-Miller

Thanks Mike. We are both having success with Wistia API code but are stuck on the linking inside SL2. I've gone down the 'web object' route to embed my video in the hope I could somehow use javascript inside SL2 to run a script on my embed video html page and return a result back to SL2. However not making much progress with that so far. Maybe you'll make some progress at the weekend.

By the way I have been testing video playback on Windows PC, iPads and Android Tablets. A Wistia hosted video plays back fine on all devices if simply run from a html page  on a web server.

However when embedded inside Storyline the Adroid html5 playback puts up a fullscreen error i.e. it always tries to go fullscreen. In newer versions of Android you are allowed to bypass the prompt, in older versions you must go full screen otherwise the video window disappears.  I have manually coded all the Fullscreen options in the embed code to 'false' but can't stop it.  I have the fullscreen button unchecked in the video options.

This is based on a web object so it may not occur is inserted as "Insert Video from Website".  

  

Mike B.

Trevor,

I think I figured it out. Here's the code I used to set a variable from within the embedded object (note the "parent." before "GetPlayer", that's what fixed it):

<script src="http://fast.wistia.net/assets/external/E-v1.js"></script>
<iframe src="http://fast.wistia.net/embed/iframe/CodeForVideo" allowtransparency="true" frameborder="0" scrolling="no" class="wistia_embed" name="wistia_embed" allowfullscreen="" mozallowfullscreen="" webkitallowfullscreen="" oallowfullscreen="" msallowfullscreen="" width="640" height="360"></iframe>

<script type="text/javascript">
wistiaEmbeds.onFind(function(video) {
video.bind("end", function() {
var player = parent.GetPlayer();
player.SetVar("EndofVideo1","on");
return this.unbind;
});
});
</script>

 

 

 

 

Trevor White-Miller

Yes your solution is working for me to. I'll have a play with other API functions next week.

I just need to test that the external embedded video inside a SCORM package will work in my client's environment. Looks like external video is the way to go if the Android issue can be managed.

I have been hunting the Storyline forums most of the day for ideas to crack the audio voice over Current Time without going to external files. Got a few ideas based on some tricks Steve Flowers uses for other unrelated topics. I'll let you know if any of them work.

This discussion is closed. You can start a new discussion or contact Articulate Support.