0

I am seek the video before it starts play. That is working fine. All videos starts play after the seek time given and playing. That is really fine.

But I cannot rewind or forward the video after that. Because if I forward or rewind video starts to play from the started seek position. Assume my seek position is from 5 minutes and I am forwarding when I am in 10th minute, the video starts again from 5 minute where my seek starts.

How can I solve this please ? This is my current code.

jwplayer('myPlayer').setup({
    file: video_url_here,
    image: video_poster_here,
    title: 'Play',
    width: '800',
    height: '500',
    skin: 'glow',
    autostart: 'true',
    primary: 'flash'
});

if(resume_time > 0) {
    jwplayer('myPlayer').onPlay(function() {
        setTimeout(function() {
        jwplayer('myPlayer').seek(resume_time);
        }, 500);
    });
}
WP Learner
  • 788
  • 1
  • 13
  • 34

2 Answers2

1

Problem

Basically, whenever your code is executed, it skips to 5 minutes.

Solution

You need to skip by 5 minutes.

  1. First get current position:
    • JWPlayer API: jwp.getPosition()
    • HTML5 Video Web API: jwp.currentTime
  2. Next, add the offset time to the current position:
    • JWPlayer API: jwp.getPosition() + offset

The following demo is using the JWPlayer API:

  1. .getPosition()
  2. .seek()
  3. .addButton()

As does your original code, it starts at an offset. The test video is only a minute long so all time offsets are in seconds.

  1. Type or scroll 0-60 seconds
  2. Click the Skip button located in the top right corner
  3. Note that the video will advance the number of seconds entered in box from the current position. So if Skip was clicked with 19.5 in the input and the player is at 26, the player should advance to 45.5.

Demo

var jwp = jwplayer('botr_xJ7Wcodt_5QOesuLn_div');

jwp.setup({
  file: '//clips.vorwaerts-gmbh.de/big_buck_bunny.mp4',
  title: 'Test Time Offset',
  width: '320',
  height: '180',
  skin: 'glow',
  key: "0H8QSBHQ3gTepr3hHusMAITnanKbD/JxzJYAKaDkZ5zwOSkLOgBqew=="
});

var offset = 5;

jwp.on('ready', function(event) {
  var now = jwp.getPosition();
  var goTo = offset + now;
  jwp.seek(goTo);
});

jwp.addButton(
  'https://www.mix96.co.uk/shared/images/sky-news-play-24.png',
  'Skip',
  function() {
    jwp.seek(
      jwp.getPosition() + (parseFloat(document.forms[0].elements[0].value)));
  },
  'skip'
);
input {
  font: inherit;
  outline: 3px inset blue;
  width: 5ch;
  margin: 10px 0 0 0
}
<script src="//content.jwplatform.com/players/xJ7Wcodt-5QOesuLn.js"></script>


<div id='botr_xJ7Wcodt_5QOesuLn_div'></div>

<form>
  <input type='number' min='0' max='60' step='1.5'> Seconds
</form>
zer00ne
  • 41,936
  • 6
  • 41
  • 68
0

Set one variable flag on click of forward or rewind and check that same condition while seek through onPlay.

var isRewindOrForward = false; // Initial load

// logic for forward and rewind here and reset isRewindOrForward to false again

if(resume_time > 0) {
jwplayer('myPlayer').onPlay(function() {
  if(!isRewindOrForward){
      setTimeout(function() {
      jwplayer('myPlayer').seek(resume_time);
      }, 500);
     }
  });
}
Yogen Darji
  • 3,230
  • 16
  • 31