player icon indicating copy to clipboard operation
player copied to clipboard

The currentTime set to a value > 0 and < 1s is not working, it will always be 0.

Open wjs opened this issue 1 year ago • 8 comments

Current Behavior:

The currentTime set to a value > 0 and < 1s is not working, it will always be 0. Cases:

  1. When I preview the video frame by frame, it will not working in the first second.
  2. When I want to get some thumbnails in the first second, it will always get the 0s as snapshot.

Expected Behavior:

The currentTime should be what I set if it is a valid value.

Steps To Reproduce:

  1. use a demo video with scene change in the first second
  2. set the current time, player.currentTime = 0.5 or remote.seek(0.5)
  3. see the if the preview has changed

Environment:

  • Framework: React
  • Node: 20.0.0
  • Chrome Version 131.0.6778.109 (Official Build) (arm64) Model Name: MacBook Pro Model Identifier: Mac15,3 Model Number: Z1C80004ECH/A Chip: Apple M3 Total Number of Cores: 8 (4 performance and 4 efficiency) Memory: 16 GB System Firmware Version: 11881.41.5 OS Loader Version: 11881.41.5

Anything Else?

wjs avatar Dec 12 '24 07:12 wjs

I am facing the same issue. currentTime automatically sets to 0 when I set it under 1 second.

ameytessact avatar Dec 17 '24 07:12 ameytessact

Confirmed to have the same issue.

ndeshpande2022 avatar Jan 15 '25 17:01 ndeshpande2022

This seems to come from this logic here: https://github.com/vidstack/player/blob/01ba2f29a08d035615678adf1e170e1e44a72c38/packages/vidstack/src/core/state/media-request-manager.ts#L770

This seems by design, but can't find any documentation about this behavior. Notice it will also happen on seeking within the last 1 nominal second of the clip.

I'm not sure yet if there is a decent way around this.

francamps avatar Mar 31 '25 15:03 francamps

This is still a major issue. Is this package still being maintained?

ndeshpande2022 avatar May 14 '25 11:05 ndeshpande2022

Any updates regarding this issue, I'm also running into problems caused by this.

Renzzauw avatar Jul 02 '25 12:07 Renzzauw

Also having this issue trying to seek frame by frame on a 10fps video. It would be nice to be able to disable the boundTime behavior. I'm using web components, but listening for the media-seek-request event, and when the seekTime is between 0 and 1, preventing the default behavior and handling the seek on the video element manually seems to be a viable workaround for bounding at the start of the video. Something like this:

videoPlayer.addEventListener('media-seek-request', (e) => {
      const seekTime = e.detail;
      if (seekTime > 0 && seekTime < 1) {
        e.preventDefault();

        let videoElement = videoPlayer.querySelector('video');
        if (videoElement) {
          videoElement.currentTime = seekTime;
        }
      }
    });

Working around the end of the video is even more hacky. Best I could manage was adding a buffer second to the duration of the video, preventing seeking/playing past the true end of the video, and manually translating the slider to account for the buffer on time-update.

jackcmac avatar Jul 08 '25 08:07 jackcmac

Working around the end of the video is even more hacky. Best I could manage was adding a buffer second to the duration of the video, preventing seeking/playing past the true end of the video, and manually translating the slider to account for the buffer on time-update.

Hey @jackcmac, can you share this approach with code? The seektime hack for 0 to 1 works and was helpful, thanks!

ameytessact avatar Jul 09 '25 11:07 ameytessact

This worked as a hack for me, solving both the 0 to 1 issue and the video playing again from start after ended issue.

onMediaSeekRequest={(seekTime, e) => {
  if (props.clipStartTime || props.clipEndTime) return;

  e.preventDefault();
  player?.$state.ended.set(false);
  const playerVideoElement = player?.$el?.querySelector('video') as HTMLVideoElement;
  if (playerVideoElement) {
    playerVideoElement.currentTime = seekTime;
  }
}}

Edit: This is breaking the currentTime state from useMediaState if clipStartTime and clipEndTime has been given.

ameytessact avatar Jul 09 '25 12:07 ameytessact