LibMedia+LibWeb: Add an initial Starting state to PlaybackManager

This state will indicate to the media element that it's not guaranteed
to have a frame yet, for the purposes of determining the ready state.
JavaScript should be sure that video elements with a ready state of
HAVE_CURRENT_DATA or greater represent the current video frame already.

To allow the state to be exited if audio is disabled, audio tracks are
now only added to the buffering set on enable if the audio sink exists,
since without the sink starting the data provider, it will never be
removed.

This is a step towards making video ref tests.
This commit is contained in:
Zaggy1024
2026-04-18 05:33:02 -05:00
committed by Gregory Bertilson
parent e1e752cc28
commit 08faa83340
Notes: github-actions[bot] 2026-04-22 00:13:12 +00:00
13 changed files with 98 additions and 20 deletions

View File

@@ -1743,7 +1743,9 @@ void HTMLMediaElement::on_metadata_parsed()
});
}
// AD-HOC: If we've already got buffered data, we need to upgrade the readyState further than HAVE_METADATA.
// AD-HOC: Now that we've enabled one of each available track type, the playback manager can be started. If this
// causes the playback manager to exit the initial state, the ready state should change.
m_playback_manager->start();
update_ready_state();
}
@@ -2127,7 +2129,8 @@ void HTMLMediaElement::update_ready_state()
auto current_range = ranges.range_at_or_after(current_time);
auto available_data = m_playback_manager->available_data();
if (available_data == Media::AvailableData::Current && !current_range.has_value()) {
if (available_data == Media::AvailableData::None
|| (available_data == Media::AvailableData::Current && !current_range.has_value())) {
// 1. Set the HTMLMediaElement's readyState attribute to HAVE_METADATA.
set_ready_state(ReadyState::HaveMetadata);
// 2. Abort these steps.