-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to use HTML5 audio tag with API Web Audio #1767
Conversation
… HTML5 audio tag and use it with WebAudio features.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR!
What was your incentive to implement this new backend?
My guess would be some people might want to use a media element but control it via Web Audio?
If I load a big audio file with WebAudio backend, because it internally decodes the AudioBuffer, the browser crashes. Using HTML5 tag, the audio data are not decoded, so in case of a big audio file browser does not crash. Moreover, in this way I can use it with API Web Audio and add filters, like control left and right channels, pannerNode, equalizer, etc |
Even with an HTML5 media element, the audio data is still decoded to draw the waveform. |
But giving peaks, the waveform is drawn with them, no? |
Yes, correct. |
With WebAudio backend, even if i give peaks to draw the waveform, it internally decodes the audio to transform it to an AudioBuffer and put it to AudioBufferSourceNode. So the waveform is drawn without any problems, but in case of big audio files, the browser crashes because it decodes the data in memory. |
Cool, gotcha. |
Maybe, we can remove private to functions like createScriptNode, createVolumeNode and Analyser, so we can extend them normally |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the support of big files is important, it is good to talk about a solution
- Put the possibility of handle audio tag with API Web Audio directly in the MediaElement backend, setting a new wavesurfer boolean parameter, 'mediaElementWebAudio', to true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, that greatly simplified things.
As per my previous comments, could you please restore the empty lines as they were in all the changed files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Thanks a lot!
We just need to add the new backend type to the docs now. The docs are on another branch, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you also look at simple unit tests (see existing MediaElement tests)?
Have I run your karma tests or write other tests? |
before pushing pull requests one should always run the tests with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added examples and updated CHANGES.md (updating changelog caused conflicts).
I don't see the example?
|
Hi @marizuccara / @thijstriemstra / @katspaugh , I used 'MediaElementWebAudio' backend. It does not load whole audio and I am also able to use filters to the mute channel. One issue I found is when I load the audio file from s3 it is giving error 'MediaElementAudioSource outputs zeroes due to CORS access restrictions' I am able to resolve this issue by adding line media.crossOrigin = "anonymous" in the load method of wavesurfer at line 1955.
Is it right resolution for this problem? |
Hi! Thanks for the feedback! You should be able also to create yourself an audio tag. |
Hi @marizuccara I got impression from the documentation and code that I could only pass the audio URL in the load method not audio object. |
can we add this line to the example? |
merged. thanks @marizuccara! |
Thanks a lot, @marizuccara! A great contribution! |
Thanks so much to you, @katspaugh and @thijstriemstra, for this fantastic library and for the support! |
Looking forward to releasing new version as soon as possible |
Hi @katspaugh / @thijstriemstra When are you planning to release new version with these changes? |
Documentation first needs to be updated and stuff. See #1782 |
Introduced the WebAudioMedia backend which allows to load audio as HTML5 audio tag and use it with WebAudio backend.
Setting the WebAudioMedia backend,there is a possibility to load audio of big dimensions, using the API Web Audio features. In this way, filters and other functionalities can be performed as with WebAudio backend without decoding internally audio data, that caused crash of the browser.
Breaking in the external API:
Added the WebAudioMedia backend. The API to use to load an audio or playback it, are the same as with the MediaElement backend.
Breaking changes in the internal API:
Added a file WebAudioMedia that extends WebAudio. Instead of using the AudioBufferSourceNode to push the source to the AudioContext, it was used the MediaElementSourceNode which takes in input the audio tag. Since an HTML5 file is loaded, there were used APIs of MediaElement backend.
Todos/Notes:
It was created another backend to test this functionality and show you my proposal. In fact, I have duplicated the MediaElement code because the resource is handled as HTML5 audio tag. For other operations, there were used WebAudio APIs.
Related Issues and other PRs:
fixes #1763