mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-26 03:09:08 +00:00
LibWeb: Begin implementing the HTMLAudioElement for audio playback
This uses LibAudio to attempt to decode resoures downloaded with <audio> elements, and draws some basic media controls for the element.
This commit is contained in:
committed by
Andreas Kling
parent
c89fd6dff0
commit
ac2238ee70
@@ -4,8 +4,11 @@
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/HTML/AudioTrack.h>
|
||||
#include <LibWeb/HTML/AudioTrackList.h>
|
||||
#include <LibWeb/HTML/HTMLAudioElement.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
#include <LibWeb/Layout/AudioBox.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
@@ -24,4 +27,33 @@ JS::ThrowCompletionOr<void> HTMLAudioElement::initialize(JS::Realm& realm)
|
||||
return {};
|
||||
}
|
||||
|
||||
JS::GCPtr<Layout::Node> HTMLAudioElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style)
|
||||
{
|
||||
return heap().allocate_without_realm<Layout::AudioBox>(document(), *this, move(style));
|
||||
}
|
||||
|
||||
Layout::AudioBox* HTMLAudioElement::layout_node()
|
||||
{
|
||||
return static_cast<Layout::AudioBox*>(Node::layout_node());
|
||||
}
|
||||
|
||||
Layout::AudioBox const* HTMLAudioElement::layout_node() const
|
||||
{
|
||||
return static_cast<Layout::AudioBox const*>(Node::layout_node());
|
||||
}
|
||||
|
||||
void HTMLAudioElement::on_playing()
|
||||
{
|
||||
audio_tracks()->for_each_enabled_track([](auto& audio_track) {
|
||||
audio_track.play({});
|
||||
});
|
||||
}
|
||||
|
||||
void HTMLAudioElement::on_paused()
|
||||
{
|
||||
audio_tracks()->for_each_enabled_track([](auto& audio_track) {
|
||||
audio_track.pause({});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user