LibMedia: Clamp PlaybackManager::current_time() to the duration

This allows LibWeb to detect the end of playback and pause playback or
loop to the start.
This commit is contained in:
Zaggy1024 2025-10-07 15:43:40 -05:00 committed by Jelle Raaijmakers
parent 16b296c090
commit bf0219d798

View File

@ -47,8 +47,8 @@ public:
static DecoderErrorOr<NonnullRefPtr<PlaybackManager>> try_create(ReadonlyBytes data);
~PlaybackManager();
AK::Duration current_time() const { return m_time_provider->current_time(); }
AK::Duration duration() const;
AK::Duration current_time() const { return min(m_time_provider->current_time(), duration()); }
VideoTracks const& video_tracks() const { return m_video_tracks; }
Optional<Track> preferred_video_track();