3

I want the client to automatically connect to the server when the connection is back and the video should start playing where it stopped before. Is it possible..?

Till now i tried making connection again after 3 seconds and video starts from first.

jwplayer().onBuffer(function()
{
    theTimeout = setTimeout(function()
    {
       window.location = window.location.href;
    },3000);
});

But i want the video to start from where it stopped playing before.. can anyone help me regarding this problem..?

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364

1 Answers1

0

How about something like this?

http://support.jwplayer.com/customer/portal/articles/1442607-example-a-custom-error-message

jwplayer().onBuffer(function(){
theTimeout = setTimeout(function(){
jwplayer().load({file:"http://example.com/errorfile.mp4",image:"http://example.com/errorfile.jpg"});
jwplayer().play();
},5000);
});

Edit, try this:

jwplayer().onBuffer(function(){
var thePosition = jwplayer().getPosition();
theTimeout = setTimeout(function(){
jwplayer().load({file:"http://example.com/errorfile.mp4",image:"http://example.com/errorfile.jpg"});
jwplayer().seek(thePosition );
},5000);
});
emaxsaun
  • 4,191
  • 2
  • 13
  • 13
  • Sir, But i want the same video to play again and from the position the connection was lost previously. Just like handling handover from one network to another. – Ram Kumar Vooda Mar 31 '15 at 06:35
  • Is it a VOD file or a live stream? – emaxsaun Mar 31 '15 at 14:49
  • but onBuffer() function is not working fine... This function is starting when the video is starting and video is ending after the timeout mentioned in the function..| But i want the video to be loaded again when connection is lost and retained. can you help in clearing my doubt..? – Ram Kumar Vooda Apr 02 '15 at 04:56
  • I am not sure what you are asking here. My code above will make the player see if it takes too long to buffer, captures the current seek time, and then re-loads the file and then re-seeks to that time. Is that not what you want to do? – emaxsaun Apr 02 '15 at 14:57
  • here in your code, you are using onBuffer(), which reloads the page after the time(which is measured from starting of video), which is mentioned in the setTimeout() function. Here(in your code) it is 5 seconds. But what i want to do is, if in video when it stops buffering then the timeout function should trigger and do the remaining things as seeking the position where it stopped before. So, im saying using onBuffer is not ideal solution in my case since it measures time from very starting point of video. So any other function that might help the case, it should trigger once the buffer stops – Ram Kumar Vooda Apr 03 '15 at 08:23
  • I am not re-loading the page. I am checking if the player times out via buffering, then re loading the player. The page does not reload here. – emaxsaun Apr 03 '15 at 14:49
  • sir, How to make this particular change in the player code.? Till now Im doing script on the webpage, but can we put this code in player source code which i got from Github. If we can, which file i should be modifying.? Thanks in advance – Ram Kumar Vooda Apr 08 '15 at 18:34
  • This code is not meant to go into the player source. It is meant to go on the webpage only. – emaxsaun Apr 08 '15 at 21:33
  • No supported to do it in that way. – emaxsaun Apr 09 '15 at 21:04