0

There's a seeked event fired in video.js each time I've sought manually or changed with player.currentTime(time). Is there any possibility to distinguish those workflows?

Thanks.

Agnislav
  • 299
  • 1
  • 9

1 Answers1

1

One option is to monkey-patch player.currentTime so that it sets some variable (say, records a timestamp) when it is called. You could then check that timestamp in the seeked handler and decide if currentTime had been called recently enough for it to be likely cause of the seeked event.

var timeOfLastTimeChange = 0;
(function() {
    var realCT = player.__proto__.currentTime;
    player.__proto__.currentTime = function(time) {
        timeOfLastTimeChange = Date.now();
        return realCT.apply(this, arguments);
    }
})();

Then do Date.now() - timeOfLastTimeChange in your seeked handler to see the number of milliseconds since currentTime was called. If it's greater than some threshold, assume the change happened due to user interaction.

apsillers
  • 112,806
  • 17
  • 235
  • 239