THEOplayer / react-native-theoplayer

A React Native THEOplayerView component
https://theoplayer.github.io/react-native-theoplayer/
MIT License
55 stars 21 forks source link

Seeking on LiveStream #342

Open Veryyapeee opened 1 week ago

Veryyapeee commented 1 week ago

Hi, I have a couple questions

I'm using the example live stream url:

https://livesim.dashif.org/livesim/chunkdur_1/ato_7/testpic4_8s/Manifest.mpd

And I'd like to ask:

  1. Is there any recommended way of checking if current progress is on stream's live edge? I've been trying to use the ProgressEvent with currentTime

So comparing the player.currentTime from TimeUpdateEvent with .seekable[0].end but it seems not reliable

Sometimes the .end property is higher than currentTime

  1. What is the best way of seeking to start of the stream (start of seekable/dvr window)?

When I'm seeking to player.seekable[0].start sometimes it's working like a charm, and sometimes player is getting stuck (like like we missed the window by couple of ms) and it's getting back to the live edge

tvanlaerhoven commented 6 days ago

Hi @Veryyapeee ,

  1. The player.seekable property indeed returns the range, or list of ranges, in which the player is allowed to seek. For a live stream this is a sliding window that is updated on each manifest download. The manifest also indicates how much the player is recommended to stay before the actual live edge, to allow for buffering. So if you want to visualize whether the player is currently streaming on (or near) live, you'd need to compare the current time with the seekable end, but allow for some margin. Returning to 'live' (the end of the seekable range) can be done by setting the currentTime to Infinite.

  2. This would be the correct way to seek to the start of the window. On which platform did you experience the snap-back to live?

Veryyapeee commented 6 days ago

Hi @Veryyapeee ,

  1. The player.seekable property indeed returns the range, or list of ranges, in which the player is allowed to seek. For a live stream this is a sliding window that is updated on each manifest download. The manifest also indicates how much the player is recommended to stay before the actual live edge, to allow for buffering. So if you want to visualize whether the player is currently streaming on (or near) live, you'd need to compare the current time with the seekable end, but allow for some margin. Returning to 'live' (the end of the seekable range) can be done by setting the currentTime to Infinite.
  2. This would be the correct way to seek to the start of the window. On which platform did you experience the snap-back to live?
  1. On AndroidTV with 7.5.0 SDK, AndroidTV on Android 34 API
Veryyapeee commented 6 days ago

Hi @Veryyapeee ,

  1. The player.seekable property indeed returns the range, or list of ranges, in which the player is allowed to seek. For a live stream this is a sliding window that is updated on each manifest download. The manifest also indicates how much the player is recommended to stay before the actual live edge, to allow for buffering. So if you want to visualize whether the player is currently streaming on (or near) live, you'd need to compare the current time with the seekable end, but allow for some margin. Returning to 'live' (the end of the seekable range) can be done by setting the currentTime to Infinite.
  2. This would be the correct way to seek to the start of the window. On which platform did you experience the snap-back to live?

Here is how it's look like

So when I'm pressing the "Start over" button, I'm setting player's current time to player.seekable[0].start

And sometimes as you can see, player is getting stack for a second and is going back to previous position by itself, and sometimes seek is working correctly

https://github.com/THEOplayer/react-native-theoplayer/assets/43120132/e63431f4-4845-47d1-90e3-3dd5c100eb68

tvanlaerhoven commented 5 days ago

@Veryyapeee could you try if seeking to the start of the seekable range + a small margin (few 100 msec) works better?

Veryyapeee commented 5 days ago

@Veryyapeee could you try if seeking to the start of the seekable range + a small margin (few 100 msec) works better?

I've tried, I've added few seconds margin, then it's working

Seems like small margin can't do the trick

tvanlaerhoven commented 5 days ago

@Veryyapeee it works when you seek before the seekable range updates. If the manifest updates before seeking, current time could fall outside the window. In that case it should clamp to the range, which apparently it doesn't. We'll look into this issue. Did you also reach out to our service desk? It might be good to log a ticket there as well, so we have the right context.