LibWeb+LibWebView+WebContent: Inform chromes when audio is played/paused

Most browsers have some indicator when audio is playing in a tab, which
makes it easier to find that tab and mute unwanted audio. This adds an
IPC to allow the Ladybird chromes to do something similar.
This commit is contained in:
Timothy Flynn 2024-03-26 19:27:06 -04:00 committed by Andreas Kling
parent 5424135d81
commit 40c0dd81d2
Notes: sideshowbarker 2024-07-17 02:08:15 +09:00
11 changed files with 63 additions and 1 deletions

View file

@ -18,6 +18,7 @@
#include <LibWeb/Fetch/Infrastructure/FetchController.h>
#include <LibWeb/Fetch/Infrastructure/HTTP/Requests.h>
#include <LibWeb/Fetch/Infrastructure/HTTP/Responses.h>
#include <LibWeb/HTML/AudioPlayState.h>
#include <LibWeb/HTML/AudioTrack.h>
#include <LibWeb/HTML/AudioTrackList.h>
#include <LibWeb/HTML/CORSSettingAttribute.h>
@ -35,6 +36,7 @@
#include <LibWeb/HTML/VideoTrackList.h>
#include <LibWeb/Layout/Node.h>
#include <LibWeb/MimeSniff/MimeType.h>
#include <LibWeb/Page/Page.h>
#include <LibWeb/Painting/Paintable.h>
#include <LibWeb/WebIDL/Promise.h>
@ -1602,6 +1604,9 @@ void HTMLMediaElement::set_paused(bool paused)
if (auto* paintable = this->paintable())
paintable->set_needs_display();
set_needs_style_update(true);
if (m_audio_tracks->has_enabled_track())
document().page().client().page_did_change_audio_play_state(paused ? AudioPlayState::Paused : AudioPlayState::Playing);
}
// https://html.spec.whatwg.org/multipage/media.html#blocked-media-element