Skip to content

Commit

Permalink
LibWeb: Add AudioContext.createMediaElementSource() factory method
Browse files Browse the repository at this point in the history
  • Loading branch information
tcl3 committed Jan 15, 2025
1 parent e94b1b4 commit a2af6ff
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
8 changes: 8 additions & 0 deletions Libraries/LibWeb/WebAudio/AudioContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,4 +318,12 @@ bool AudioContext::start_rendering_audio_graph()
return render_result;
}

// https://webaudio.github.io/web-audio-api/#dom-audiocontext-createmediaelementsource
WebIDL::ExceptionOr<GC::Ref<MediaElementAudioSourceNode>> AudioContext::create_media_element_source(GC::Ptr<HTML::HTMLMediaElement> media_element)
{
MediaElementAudioSourceOptions options;
options.media_element = media_element;
return MediaElementAudioSourceNode::create(realm(), *this, options);
}

}
3 changes: 3 additions & 0 deletions Libraries/LibWeb/WebAudio/AudioContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <LibWeb/Bindings/AudioContextPrototype.h>
#include <LibWeb/HighResolutionTime/DOMHighResTimeStamp.h>
#include <LibWeb/WebAudio/BaseAudioContext.h>
#include <LibWeb/WebAudio/MediaElementAudioSourceNode.h>

namespace Web::WebAudio {

Expand Down Expand Up @@ -39,6 +40,8 @@ class AudioContext final : public BaseAudioContext {
WebIDL::ExceptionOr<GC::Ref<WebIDL::Promise>> suspend();
WebIDL::ExceptionOr<GC::Ref<WebIDL::Promise>> close();

WebIDL::ExceptionOr<GC::Ref<MediaElementAudioSourceNode>> create_media_element_source(GC::Ptr<HTML::HTMLMediaElement>);

private:
explicit AudioContext(JS::Realm&, AudioContextOptions const& context_options);

Expand Down
2 changes: 1 addition & 1 deletion Libraries/LibWeb/WebAudio/AudioContext.idl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface AudioContext : BaseAudioContext {
Promise<undefined> resume ();
Promise<undefined> suspend ();
Promise<undefined> close ();
[FIXME] MediaElementAudioSourceNode createMediaElementSource (HTMLMediaElement mediaElement);
MediaElementAudioSourceNode createMediaElementSource (HTMLMediaElement mediaElement);
[FIXME] MediaStreamAudioSourceNode createMediaStreamSource (MediaStream mediaStream);
[FIXME] MediaStreamTrackAudioSourceNode createMediaStreamTrackSource (MediaStreamTrack mediaStreamTrack);
[FIXME] MediaStreamAudioDestinationNode createMediaStreamDestination ();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Harness status: OK

Found 302 tests
Found 304 tests

291 Pass
11 Fail
294 Pass
10 Fail
Pass # AUDIT TASK RUNNER STARTED.
Pass Executing "initialize"
Pass Executing "Offline createGain"
Expand All @@ -24,7 +24,7 @@ Fail Executing "Offline createScriptProcessor"
Pass Executing "Offline createPeriodicWave"
Pass Executing "Offline createChannelSplitter"
Pass Executing "Offline createChannelMerger"
Fail Executing "Online createMediaElementSource"
Pass Executing "Online createMediaElementSource"
Fail Executing "Online createMediaStreamDestination"
Pass Executing "AudioListener"
Pass Executing "verifyTests"
Expand Down Expand Up @@ -241,6 +241,8 @@ Pass > [Offline createChannelMerger]
Pass AudioNode has no AudioParams as expected
Pass < [Offline createChannelMerger] All assertions passed. (total 1 assertions)
Pass > [Online createMediaElementSource]
Pass MediaElementAudioSourceNode has no AudioParams as expected
Pass < [Online createMediaElementSource] All assertions passed. (total 1 assertions)
Pass > [Online createMediaStreamDestination]
Pass > [AudioListener]
Pass AudioListener.positionX.minValue is equal to -3.4028234663852886e+38.
Expand Down

0 comments on commit a2af6ff

Please sign in to comment.