4 ms·
Or as the developer you can play some silent audio in the background via an `<audio>` element: https://github.com/donbrae/onscreen-piano-keyboard/blob/main/src/
by donbrae 1y ago
Or as the developer you can play some silent audio in the background via an `<audio>` element: https://github.com/donbrae/onscreen-piano-keyboard/blob/main/src/index.js#L160-L179 https://github.com/donbrae/onscreen-piano-keyboard/blob/main.... This will ensure the Web Audio API produces sound even with the ‘silent’ switch active.
- wesz 1y agoInteresting, i already do something similar and never had a chance to check if it really works. Here is my code: var buffer = dm.audio.createBuffer(1, 1, dm.samplerate); var source = dm.audio.createBufferSource(); source.buffer = buffer; source.connect(dm.audio.destination); if (source.start) { source.start(0); } else { source.noteOn(0); }
- jaflo 1y agoI believe you need to use the audio element specifically. The Web Audio API is subject to different restrictions than the audio element. I used a similar approach on Audjust: https://www.audjust.com/blog/unmute-web-audio-on-ios/ https://www.audjust.com/blog/unmute-web-audio-on-ios/ (nice site you created btw! I love seeing audio stuff for the web)
- wesz 1y agoThanks mate! I'll implement your solution:)
- matteason 1y agoI hit this on https://ambiph.one https://ambiph.one - my solution ended up being similar (use an <audio> element) but because I also wanted audio to play in the background and when the screen is off there's an extra step of tricking Safari into thinking it's playing a livestream, since apparently that's the only kind of audio Apple thinks should be allowed to play in the background. Coincidentally someone asked me about this the other day so I put together a minimal demo here in case it's useful to anyone: https://codepen.io/matteason/pen/VYwdzVV https://codepen.io/matteason/pen/VYwdzVV