mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
LibMedia+LibWeb: Rewrite PlaybackManager using the provider/sink model
With this commit, all PlaybackManager can do is autoplay a file from start to finish, with no pausing or seeking functionality. All audio playback functionality has been removed from HTMLMediaElement and HTMLAudioElement in anticipation of PlaybackManager taking that over, for both audio-only and audio/video.
This commit is contained in:
parent
0f9fa47352
commit
6caa2f99aa
Notes:
github-actions[bot]
2025-10-28 00:35:44 +00:00
Author: https://github.com/Zaggy1024
Commit: 6caa2f99aa
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6410
Reviewed-by: https://github.com/R-Goc
Reviewed-by: https://github.com/gmta ✅
15 changed files with 371 additions and 1234 deletions
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
#include <LibGfx/Bitmap.h>
|
||||
#include <LibMedia/Sinks/DisplayingVideoSink.h>
|
||||
#include <LibWeb/Bindings/HTMLVideoElementPrototype.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/CSS/ComputedProperties.h>
|
||||
|
|
@ -44,9 +45,6 @@ void HTMLVideoElement::initialize(JS::Realm& realm)
|
|||
void HTMLVideoElement::finalize()
|
||||
{
|
||||
Base::finalize();
|
||||
|
||||
for (auto video_track : video_tracks()->video_tracks())
|
||||
video_track->stop_video({});
|
||||
}
|
||||
|
||||
void HTMLVideoElement::visit_edges(Cell::Visitor& visitor)
|
||||
|
|
@ -109,62 +107,6 @@ u32 HTMLVideoElement::video_height() const
|
|||
return m_video_height;
|
||||
}
|
||||
|
||||
void HTMLVideoElement::set_video_track(GC::Ptr<HTML::VideoTrack> video_track)
|
||||
{
|
||||
set_needs_style_update(true);
|
||||
if (auto layout_node = this->layout_node())
|
||||
layout_node->set_needs_layout_update(DOM::SetNeedsLayoutReason::HTMLVideoElementSetVideoTrack);
|
||||
|
||||
if (m_video_track)
|
||||
m_video_track->pause_video({});
|
||||
|
||||
m_video_track = video_track;
|
||||
}
|
||||
|
||||
void HTMLVideoElement::set_current_frame(Badge<VideoTrack>, RefPtr<Gfx::Bitmap> frame, double position)
|
||||
{
|
||||
m_current_frame = { move(frame), position };
|
||||
if (paintable())
|
||||
paintable()->set_needs_display();
|
||||
}
|
||||
|
||||
void HTMLVideoElement::on_playing()
|
||||
{
|
||||
if (m_video_track)
|
||||
m_video_track->play_video({});
|
||||
|
||||
audio_tracks()->for_each_enabled_track([](auto& audio_track) {
|
||||
audio_track.play();
|
||||
});
|
||||
}
|
||||
|
||||
void HTMLVideoElement::on_paused()
|
||||
{
|
||||
if (m_video_track)
|
||||
m_video_track->pause_video({});
|
||||
|
||||
audio_tracks()->for_each_enabled_track([](auto& audio_track) {
|
||||
audio_track.pause();
|
||||
});
|
||||
}
|
||||
|
||||
void HTMLVideoElement::on_seek(double position, MediaSeekMode seek_mode)
|
||||
{
|
||||
if (m_video_track)
|
||||
m_video_track->seek(AK::Duration::from_milliseconds(position * 1000.0), seek_mode);
|
||||
|
||||
audio_tracks()->for_each_enabled_track([&](auto& audio_track) {
|
||||
audio_track.seek(position, seek_mode);
|
||||
});
|
||||
}
|
||||
|
||||
void HTMLVideoElement::on_volume_change()
|
||||
{
|
||||
audio_tracks()->for_each_enabled_track([&](auto& audio_track) {
|
||||
audio_track.update_volume();
|
||||
});
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/media.html#attr-video-poster
|
||||
WebIDL::ExceptionOr<void> HTMLVideoElement::determine_element_poster_frame(Optional<String> const& poster)
|
||||
{
|
||||
|
|
@ -245,4 +187,12 @@ WebIDL::ExceptionOr<void> HTMLVideoElement::determine_element_poster_frame(Optio
|
|||
return {};
|
||||
}
|
||||
|
||||
RefPtr<Gfx::Bitmap> HTMLVideoElement::bitmap() const
|
||||
{
|
||||
auto const& sink = selected_video_track_sink();
|
||||
if (sink == nullptr)
|
||||
return nullptr;
|
||||
return sink->current_frame();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue