mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
LibWeb: Ensure that media elements can seek to the duration
Due to the round trip of Duration -> double -> Duration, seeking to the end of some media can sometimes result in the seek being resolved close to the end but not quite there. This is a little bit of a hack to make that work, but may be necessary depending on how the spec changes with regard to the value returned by currentTime after a seek begins.
This commit is contained in:
committed by
Jelle Raaijmakers
parent
cb1719aa81
commit
9e4c87ab85
Notes:
github-actions[bot]
2025-10-28 00:30:50 +00:00
Author: https://github.com/Zaggy1024 Commit: https://github.com/LadybirdBrowser/ladybird/commit/9e4c87ab850 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6410 Reviewed-by: https://github.com/R-Goc Reviewed-by: https://github.com/gmta ✅
@@ -1787,8 +1787,14 @@ void HTMLMediaElement::seek_element(double playback_position, MediaSeekMode seek
|
||||
|
||||
// 12. Wait until the user agent has established whether or not the media data for the new playback position is
|
||||
// available, and, if it is, until it has decoded enough data to play back that position.
|
||||
if (m_playback_manager)
|
||||
m_playback_manager->seek(AK::Duration::from_seconds_f64(playback_position), manager_seek_mode);
|
||||
if (m_playback_manager) {
|
||||
AK::Duration new_playback_position_as_duration;
|
||||
if (playback_position == m_duration)
|
||||
new_playback_position_as_duration = m_playback_manager->duration();
|
||||
else
|
||||
new_playback_position_as_duration = AK::Duration::from_seconds_f64(playback_position);
|
||||
m_playback_manager->seek(new_playback_position_as_duration, manager_seek_mode);
|
||||
}
|
||||
|
||||
// 13. Await a stable state. The synchronous section consists of all the remaining steps of this algorithm. (Steps in the
|
||||
// synchronous section are marked with ⌛.)
|
||||
|
||||
Reference in New Issue
Block a user