Is there a way to fetch *previous* DVR window from HLS stream in React Native Video?

50 views Asked by At

I have a React Native app using react-native-video with react-native-video-controls and everything works as you'd expect. There is only one issue I can't seem to figure out.

When you 'start' the stream (onLoad), the left-most bound of the DVR window is the instant you loaded it - You cannot seek 'before' the time in which you started the video.

Here is my seek functionality:

const handleSeek = (num: number) => {
  // Abandon if too son or not loaded (for retouch crash)
  if (!videoRef.current || videoRef.current.state.seeking === true || (Date.now() - lastTouched < 250)) return
  // Separate logic from HLS/Live versus non-live
  if (props.isLive) {
    const seekDestination = (Math.max(0, Math.min((videoRef.current.state.currentTime + num), playableDuration.current)))
    videoRef.current.player.ref.seek(seekDestination)
    return
  } else {
    const seekDestination = (Math.max(0, Math.min((videoRef.current.state.currentTime + num), videoRef.current.state.duration)))
    videoRef.current.player.ref.seek(seekDestination)
    MusicControl.updatePlayback({
      elapsedTime: seekDestination
    })
    setLastTouched(Date.now())
  }
}

It's messy right now just to fork it, but I'll clean it up after it does what I intend it to do (which is to go to a time before the video was instantiated)

0

There are 0 answers