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

JW 6.x bug on HTML5 mode - seek inside onSeek event does nothing


Hey there,

I am facing a problem that it is definitely a bug of JWPlayer when it works in HTML5 (in Flash mode everything works properly). I am using JW 6.8 but it is not fixed in 6.9 version as well.

The problem is that when I declare an "onSeek" event and calling seek function inside it nothing happens. For example see the code below, which normally on the first seeking of the player with the use of the control bar, video should seek at second 120....but it doesn't :

var is_seeking = 0;
jwplayer().onSeek(function(event){
if(is_seeking == 0){
is_seeking = 1;
jwplayer().seek(120); //THIS DOES NOTHING AT ALL WHEN JW IS IN HTML5 MODE!!!!
return false;
}
}

Thanks a lot in advance!

10 Community Answers

Ethan Feldman

JW Player Support Agent  
0 rated :

Can I see a link to where this is running?

nickorfas

User  
0 rated :

It is a little bit difficult because I am working localhost at this stage of the project.

You can have a test and see the problem by yourself in a simple Javascript setup of JWPlayer 6.8 or 6.9. Just create an onSeek event and inside it try to seek to any second of the video....you will see that nothing happens (when you are on HTML5 mode).

Thank you very much for your interest!

Ethan Feldman

JW Player Support Agent  
0 rated :

Hm, I see what you mean. What are you ultimately trying to accomplish here?

nickorfas

User  
0 rated :

My project has to do with virtual trims and cuts. So I have some video time periods that I need to jump.

When I reach the starting point of a trim/cut I use seek method for jumping to the end point of trim/cut inside an onTime event.

The problems comes when the user goes manually via the control bar (which should be available to the users) to a video point that belongs to a trimmed/cutted period where I need onSeek event and inside it custom seek method call to the end point of the respective trimmed/cutted period that the user tried to access.

Thanks againg for your help!

Ethan Feldman

JW Player Support Agent  
0 rated :

Hm, I see.

I have done something small to disable seeking if you are seeking ahead of where you have watched, maybe something like this would work for you?

var maxPlayPosition = 0;
var seeking = false;
jwplayer().onTime(function (event) {
if (!seeking) maxPlayPosition = Math.max(event.position, maxPlayPosition)
}).onPlaylistItem(function () {
maxPlayPosition = 0
}).onSeek(function (event) {
if (!seeking) {
if (event.offset > maxPlayPosition) {
seeking = true;
setTimeout(function () {
jwplayer().seek(maxPlayPosition)
}, 100)
}
} else seeking = false
});

nickorfas

User  
0 rated :

This is not my case... I can understand what this code is for but I need offset check in terms of my trimmed/cutted time periods.

However, I believe that the code you sent will not work in HTML5 mode since it contains a seek call (jwplayer().seek(maxPlayPosition)) inside an onSeek event..... have you tried it and see if it works properly? Moreover, why have you placed a setTimeout of 100 miliseconds for triggering seek?

nickorfas

User  
0 rated :

I am so relieved!!!! The time delay of 100 milliseconds on calling the seek method inside the onSeek event DID THE MAGIC!!!

I can't understand the reason that this delay is required (probably in order to complete the onseek function before re-entering to it because of the second internal seek call) but I would like to thank you very much for your help!!!

PS...Do you have any idea why this time delay is mandatory in order seek call to have effect in HTML5 mode while in Flash mode it does not need it?.... just for stop accusing myself for wasting so many hours trying to find the reason it was not working :-)

Ethan Feldman

JW Player Support Agent  
0 rated :

Hey, that is great, glad you got it working! I bet that calling seek within an onSeek is something that is a little bit of an edge case. Nonetheless, I will bring this up with the player team.

nickorfas

User  
0 rated :

Great! Thanks a lot again!

Ethan Feldman

JW Player Support Agent  
0 rated :

Np!

This question has received the maximum number of answers.