1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:48:11 +00:00

LibWeb: Change the callback used to detect the end of a video stream

The on_end_of_stream callback was added to notify clients that video
playback has stopped when we didn't have a way to retrieve the playback
state from Video::PlaybackManager. Now that we do, we should consolidate
on using the on_playback_state_change callback to detect such changes.
This commit is contained in:
Timothy Flynn 2023-04-14 07:27:28 -04:00 committed by Linus Groh
parent c08755836d
commit 6cd50d1910

View file

@ -37,9 +37,17 @@ VideoTrack::VideoTrack(JS::Realm& realm, JS::NonnullGCPtr<HTMLMediaElement> medi
m_media_element->set_current_playback_position(playback_position_ms / 1000.0);
};
m_playback_manager->on_end_of_stream = [this]() {
auto playback_position_ms = static_cast<double>(duration().to_milliseconds());
m_media_element->set_current_playback_position(playback_position_ms / 1000.0);
m_playback_manager->on_playback_state_change = [this]() {
switch (m_playback_manager->get_state()) {
case Video::PlaybackState::Stopped: {
auto playback_position_ms = static_cast<double>(duration().to_milliseconds());
m_media_element->set_current_playback_position(playback_position_ms / 1000.0);
break;
}
default:
break;
}
};
m_playback_manager->on_decoder_error = [](auto) {