mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 06:48:49 +00:00
LibWeb: Play audio tracks alongside video tracks with the video element
The underlying media element class already parses out the audio tracks, regardless of the media type. Let's play them with videos!
This commit is contained in:
parent
4df2de2f20
commit
509eaca73d
Notes:
github-actions[bot]
2025-03-13 18:34:45 +00:00
Author: https://github.com/Lubrsi
Commit: 509eaca73d
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3892
Reviewed-by: https://github.com/ADKaster
5 changed files with 27 additions and 6 deletions
|
@ -16,6 +16,7 @@
|
|||
#include <LibWeb/Fetch/Infrastructure/FetchController.h>
|
||||
#include <LibWeb/Fetch/Infrastructure/HTTP/Requests.h>
|
||||
#include <LibWeb/Fetch/Infrastructure/HTTP/Responses.h>
|
||||
#include <LibWeb/HTML/AudioTrackList.h>
|
||||
#include <LibWeb/HTML/HTMLVideoElement.h>
|
||||
#include <LibWeb/HTML/VideoTrack.h>
|
||||
#include <LibWeb/HTML/VideoTrackList.h>
|
||||
|
@ -130,18 +131,37 @@ 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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue