polimediaupv / paella-core

Paella Player core library
Educational Community License v2.0
20 stars 15 forks source link

In Safari, Progress bar shows current time as 59:-1 when skip back past start of video #328

Closed karendolan closed 11 months ago

karendolan commented 1 year ago

In Safari, the video appears to be allowed to seek to a time before the start of the video and to a time after the end of the video.

I suspect that adding protection for mp4 setCurrentTime to set video.currentTime only to a point in 0-duration might help https://github.com/polimediaupv/paella-core/blob/main/src/js/videoFormats/es.upv.paella.mp4VideoFormat.js#L90-L94. I will attempt this locally...

To duplicate

SeekBeforeZero-Safari

SeekAfterDuration-Safari

karendolan commented 12 months ago

Verified that this patches the issue in mp4VideoFormat in Safari.

async setCurrentTime(t) {
    if (this._videoEnabled) {
      await this.waitForLoaded();
      const dur = this.video.duration;
+     if (t >= dur) {
+        // restrict seek-forward to 2 seconds to the end
+       this.video.currentTime = dur - 2;
+     }
+     else if (t < 0) {
+        // restrict seek-back to 0
+        this.video.currentTime = 0;
 +    }
 +    else {
 +       this.video.currentTime = t;
 +    }
 -    this.video.currentTime = t;
      return t;
    }
    else {
      this._disabledProperties.currentTime = t;
      return t;
    }
  }