Description
Problem with Short DVR Duration in ExoPlayer
Hi, I'm working on an improvement for my video player, which uses ExoPlayer and a custom UI. I'm currently encountering problems when playing live content with a short DVR window (e.g., 5 or 10 minutes). The issues are as follows:
1. Position is lost at the live edge when new segments arrive
When I call seekToDefaultPosition()
to move the player to the live edge, it initially works correctly. For example, if the video has a 5-minute DVR window, I start at position 4:55. However, when a new segment arrives on the HLS stream, the current position shifts backwards (e.g., to 4:45), and I'm no longer at the live edge.
I understand this happens because ExoPlayer moves the playback window as new segments are added, which causes the current position to no longer be at the end. I'd like to know if there's a way to prevent this behavior or to reliably anchor playback at the live edge.
2. Unstable live edge calculation in short DVRs
I'm currently calculating whether the user is at the live edge by checking if the current position is within a percentage of the total DVR duration from the end (e.g., 2%). This works well for long DVR windows (like 1 hour), but in live streams with only a few minutes of DVR, the margin is so small that the calculation becomes unstable. Small changes in segment arrival can cause the player to constantly toggle between live and not live.
Result
When both issues occur together, the player behaves incorrectly on short-DVR live streams, losing sync with the live edge and resulting in a poor user experience.
Any suggestions?
Is there a recommended way to handle these cases in ExoPlayer? Or a better strategy to calculate the live edge more reliably, even with short DVR durations?