-
Notifications
You must be signed in to change notification settings - Fork 432
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
decodeAudioData example does not work on Safari #5
Comments
Hrm. I tried changing the parameter to error, which is what it says it is in the spec. But it still doesn't work. This looks like a Safari bug to me - it works fine in other browsers. |
Also, the loop start and end times will not function as expected unless you un-remark the line: |
@jakelewis3d this is a good point; I've fixed that. |
@jakelewis3d does it work on safari with source.loop = true? if Yes, does it mean that percussion sounds cannot be used in safari? |
Ogg format is not supported by safari. |
Does someone fancy updating the example to offer an MP3 format file too? I will get to it eventually, but I'm crushingly busy right now. |
@chrisdavidmills See attached |
MP3 file for mdn#5
@guest271314 thanks for the valient effort at fixing this, but ... it still doesn't seem to work for me. I also tried moving the audio context creation inside a user gesture, and rewriting the forking code that chooses between ...Safari no longer errors. It now just fails silently ¯_(ツ)_/¯ |
@chrisdavidmills Do not currently have access to Safari, cannot verify the output. The closest that am able to test the code is Epiphany 3.28.5 where Safari does fail or report missing coverage for several Web Audio API methods at https://wpt.fyi/interop/webaudio/the-audio-api/the-audiobuffersourcenode-interface/audiobuffersource-multi-channels.html?label=master&label=experimental&aligned from https://github.com/web-platform-tests/wpt/blob/07d9f452d740d98ded5b11c176ba783fe9d80e5b/webaudio/the-audio-api/the-audiobuffersourcenode-interface/audiobuffersource-multi-channels.html. |
As it is marked as fixed, I tried with the steps above. But it does not work either on Safari 13.9.4 |
Have you filed a Safari bug? Have you tried https://github.com/jfrancos/oggdec-wasm as workaround? |
It's 2,5 years later as this problem was reported, and it still does not work on Safari! At least you should make a note in the code that the example is not compatible with Safari. |
I've added a note to the page. I've tried to debug this a few times now, and never gotten anywhere, which is really frustrating. I just don't have the time to have a proper look at it. |
So I have been researching a bit with the keywords "Web Audio Api Loop Demo" and found actually quite a few examples. Most of them do not work on Safari either (they do not include webkit), BUT there is this one where even 3 loops are going at the same time: https://forestmist.org/share/web-audio-api-demo Here are some more working examples and a great article about what has to be done to make the Web Audio API work in Safari: https://jakearchibald.com/2016/sounds-fun/ Another script that just does looping (without selectable start or end looping points) is at https://github.com/veltman/loopify. It works on Safari and other browsers without a glitch and is just a few lines of code, so it should be easy for a pro programmer to find the bug in the decodeAudioData example. |
After playing around with the Web Audio API for a week, I noticed the following policy in Safari: It always wants a user gesture right before you start playback. You can not invoke downloading and playing an audio file at the same time from one button click! |
@thosch6 thanks for that hint. I am still dealing with this problem more than a year later. Did you find out more since then? |
I am using jake Archibald’s solution from 2016 for my loops, but there must be more up to date code by now on the web. See my player here: https://www.guitar.ch/en/guitars/jamtracks/jamtracks-modal-mixolydian.html
… Am 21.12.2021 um 20:25 schrieb LukasAV ***@***.***>:
@thosch6 thanks for that hint. I am still dealing with this problem more than a year later. Did you find out more since then?
In a simple test I could confirm that getting the data using fetch in the same method as decodeAudioData does not work. But how far exactly do these steps have to be separated and what exactly is it about getting the data? Getting the cached file from an indexed DB did not seem to work either
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you were mentioned.
|
Thanks for the tip. let audioBuffer;
async function init() {
const audioFile = await fetchSoundArrayBuffer();
audioBuffer = await this.audioContext.decodeAudioData(audioFile);
}
function play() {
const source = this.audioContext.createBufferSource();
source.buffer = audioBuffer;
source.connect(this.audioContext.destination);
source.start();
} |
I had similar problem lately that the fix was actually using But keep in mind, Firefox and some other Non-Apple platforms won't work with So we first do check to detect iOS safari browser and use |
@shreyas-jadhav Does iOS support MP3? |
according to my tests on our app, iOS 14 fails all the time to |
Web Audio API specification https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-decodeaudiodata
Does Safari play MP3 files at HTML |
Yes it does support mp3 for Actually there might be different reason why it wasn't working for us with mp3. sorry for posting unrelated & vague solution before. |
Thanks all for the input here. It looks like this issue has been fixed by #32 which uses Thank you :) |
-> https://mdn.github.io/webaudio-examples/decode-audio-data/
does not work on safari (Version 11.0.2 (11604.4.7.1.6) on OSX 10.11.6)
Steps to reproduce
In fact the error callback gets a
null
parameter.The text was updated successfully, but these errors were encountered: