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

Problem with play() and seek() in JavaScript API


There seem to be problems with the play() and seek() functions in the player's JavaScript API.

If the stop() function is called via the API and then subsequently the play() function is called, the player does not start playing. The play() function must be called a second time before the video will play. I have to use this workaround:

if (initialState === "IDLE"
&& jwplayer(playerId).getState() !== "PLAYING"
&& jwplayer(playerId).getState() !== "BUFFERING"
) {
jwplayer(playerId).play();
}

The seek() function doesn't seem to work reliably. If I do something like

jwplayer(playerId).seek(40);

the video will often start playing at a different spot rather than 40 seconds into the recording.

10 Community Answers

Pablo

JW Player Support Agent  
0 rated :

@Robert -

Please post a link which can help demonstrate the issue you’re having.

JW Player

User  
0 rated :

It seams I have the same issue as Robert.
When I try to seek(x) somehting and the movie is not already playing it got stuck.

@PabloS: An easy test would be jwplayer().seek(10); on an video without autoplay.

Pablo

JW Player Support Agent  
0 rated :

@lony -

Seeking an unstarted player to 10 seconds works for me, but different server setups may behave differently, which is why I requested a test page from Robert. If you can provide a test page showing your problem, I can look into that as well.

JW Player

User  
0 rated :

Ok. I'll try to put something up tonight. Hopefully the error is present in this environment, too.

Thanks for your help.

JW Player

User  
0 rated :

@PabloS I put something up at http://goo.gl/7Y1rQ

The problem occurs if I open the page with an IE9 and just click on Mark b. The video seams to start but nothing happens. Same problem in Firefox11, Chrome seam to work. For further test I uploaded a couple of other movies too (click on Movie x).

Cheers lony

Pablo

JW Player Support Agent  
0 rated :

@lony -

The root of the problem here is that it’s not possible to seek to a point in the video that hasn’t been buffered yet (at least, not in Flash). It’s a bit strange that the player hangs in Firefox and IE, but even if it didn’t hang, the seek would not be possible.

In order to get this to work properly, you’ll need to use a streaming server of some sort. See:

http://www.longtailvideo.com/support/jw-player/jw-player-for-flash-v5/12534/video-delivery-http-pseudo-streaming
http://www.longtailvideo.com/support/jw-player/jw-player-for-flash-v5/12535/video-delivery-rtmp-streaming

JW Player

User  
0 rated :

Thanks I try it out.

JW Player

User  
0 rated :

@PabloS: Is it still possible to achieve a similar behavior in Firefox and IE then in Chrome?
Which means, even if it has to load content it would be nice to do so.
After I click a mark it should load the needed data and start playing afterwards. Is that possible with the other browsers too? Why is it working in Chrome?

Pablo

JW Player Support Agent  
0 rated :

@Iony -

Your example actually isn’t working for me in Chrome either. And no, it isn’t currently possible to configure the player to wait until the video is loaded and then perform the seek.

As I said before, enabling pseudo-streaming is really the only way around this. The alternative is to use the HTML5 player instead of Flash, since the HTML5 browsers do support seeking to unbuffered regions of the video.

JW Player

User  
0 rated :

Thanks. Finally understood the problem ;)

This question has received the maximum number of answers.