Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Seamless looping in JWP 7


Whether playing in HTML5 mode or flash mode, when setting "repeat: true", the loading circle appears for about 0.5 seconds at the end of each play

When using native HTML5 video this does not happen - with the repeat being seamless

I can see the question has been asked here once before:

http://support.jwplayer.com/customer/portal/questions/6062758-player-repeat-looping-pause

But seemed to tail off before being resolved. Any ideas?

6 Community Answers

ben.barker

User  
0 rated :

Btw, I used some very basic code to test this:
<div style='margin:0; overflow: hidden; padding:0; width:352px; height: 288px' id="container">
</div>

<script type="text/javascript">
var key="myKey";
var player = jwplayer('container');
var filevar='test.mp4';

player.setup({
height:'288',
width:'352',
repeat: 'true',
autostart: 'true',
primary:'flash',
key:key,
stretching: 'exactfit',
file: filevar
});
</script>

Alex

JW Player Support Agent  
0 rated :

Hi, Ben.

Can you please give me a link to a page where you have the affected player installed?

ben

User  
0 rated :

Here you go:

http://tinyurl.com/ptlx8xm

It may just be a necessary price to pay for the advantages of having a more overall flexible solution...but interestingly the chrome and FF native HTML5 video players seem to manage without the brief pause...

Alex

JW Player Support Agent  
1 rated :

Hi, Ben.

Unfortunately, that is the way the built-in “repeat” option works. It’s less of a “looping” feature and more of a “I just want the video to play again” option.

However, there is a workaround via the JavaScript API. You can see it in action and the code example on this page: http://qa.jwplayer.com/~abussey/60720-loop.html

The first function finds out the duration of the content. The second function listens to an .on(“time”) event that returns the position of playback a few times per second. Then the position of playback reaches less than one second before the end of the video, it makes the player seek back to the beginning of the video.

Hopefully, you’ll have some luck with this.

Please let me know if you need any more help or have any other questions.

Thank you!

ben

User  
0 rated :

Yep - that seems to work. Can I check a couple of things:

What is the granularity of the "getDuration" call?
When does the "play" event handler fire?

Ideally the loop will be as close to videoDuration as possible, but I don't want to risk missing it if I try to use too small a value

Alex

JW Player Support Agent  
0 rated :

Hi, Ben.

The only information that .getDuration returns is the duration of the content, in seconds. If the content is a live stream, it will return a value of “-1”. The .on(“play”) event fires when the player enters a “playing” state, so it may possibly be before the video starts playing for the viewer, so that’s why I have it setup to timeout for a second before it actually returns the duration.

The issue with this method of looping, however, is that browsers are not consistent with how often they fire the *.on(“time”) event, so if you loop the content enough times, it’s possible for the position of the video to match the duration, and so the playback stops. However, there is no real workaround for this. It all depends on whatever content you are showing, if it ends on a black screen, you may be able to increase the amount of time before the end of the video that the player goes back to the beginning.

I hope that makes sense!

This question has received the maximum number of answers.