LibWeb/WebAudio: Fire complete event with OfflineAudioCompletionEvent

This commit is contained in:
Luke Wilde 2025-11-18 16:49:02 +00:00 committed by Andreas Kling
parent 556699d601
commit 47b512ec56
Notes: github-actions[bot] 2025-11-19 16:27:18 +00:00
9 changed files with 120 additions and 14 deletions

View file

@ -13,6 +13,7 @@
#include <LibWeb/HTML/Window.h>
#include <LibWeb/WebAudio/AudioBuffer.h>
#include <LibWeb/WebAudio/AudioDestinationNode.h>
#include <LibWeb/WebAudio/OfflineAudioCompletionEvent.h>
#include <LibWeb/WebAudio/OfflineAudioContext.h>
namespace Web::WebAudio {
@ -138,9 +139,17 @@ void OfflineAudioContext::begin_offline_rendering(GC::Ref<WebIDL::Promise> promi
// 4.2: Queue a media element task to fire an event named complete at the OfflineAudioContext using OfflineAudioCompletionEvent
// whose renderedBuffer property is set to [[rendered buffer]].
// FIXME: Need to implement OfflineAudioCompletionEvent.
queue_a_media_element_task(GC::create_function(heap(), [&realm, this]() {
this->dispatch_event(DOM::Event::create(realm, HTML::EventNames::complete));
auto event_init = OfflineAudioCompletionEventInit {
{
.bubbles = false,
.cancelable = false,
.composed = false,
},
this->m_rendered_buffer,
};
auto event = MUST(OfflineAudioCompletionEvent::construct_impl(realm, HTML::EventNames::complete, event_init));
this->dispatch_event(event);
}));
}));
}