Issue Details
Version used:
Latest SoundJS 1.0.2
https://cdnjs.cloudflare.com/ajax/libs/SoundJS/1.0.2/soundjs.min.js
Whats happening:
When playing a sound using HTMLAudioPlugin, without an initial interaction, an error appears in Chrome and Safari.
soundjs.min.js:18 Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first. https://goo.gl/xX8pDD
Things still work properly, and this restriction is known, due to autoplay permissions that require an initial interaction. It's just the appearance of that error is annoying, and appearing due to not handling the promise (https://github.com/CreateJS/SoundJS/blob/master/src/soundjs/htmlaudio/HTMLAudioSoundInstance.js#L160)
MDN Spec: https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/play
OS & Browser version:
Mac OSX Sierra 10.12.6
Chrome Canary 69.0.3495.0
Chrome 67.0.3396.99
Safari 11.0.3
Do you know of any workarounds?
Prioritising WebAudioPlugin is probably suitable for most cases.
Otherwise enforcing a screen click, before any play() call.
But the error doesn't really cause any problems, so usually can be ignored.
Provide any extra details that will help us fix your issue:
Demo here:
https://codepen.io/anon/pen/mjmWyb
Opening in Chrome or Safari will fail to play the audio, and the error will show up in the JS Console.
Changing to WebAudioPlugin makes it work (click the screen to stop the sound).
It could be patched with the promise check method:
https://developers.google.com/web/updates/2016/03/play-returns-promise
Then maybe integrated with any WebAudio unlocking stuff.
Issue Details
Version used:
Latest SoundJS 1.0.2
https://cdnjs.cloudflare.com/ajax/libs/SoundJS/1.0.2/soundjs.min.js
Whats happening:
When playing a sound using HTMLAudioPlugin, without an initial interaction, an error appears in Chrome and Safari.
Things still work properly, and this restriction is known, due to autoplay permissions that require an initial interaction. It's just the appearance of that error is annoying, and appearing due to not handling the promise (https://github.com/CreateJS/SoundJS/blob/master/src/soundjs/htmlaudio/HTMLAudioSoundInstance.js#L160)
MDN Spec: https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/play
OS & Browser version:
Mac OSX Sierra 10.12.6
Chrome Canary 69.0.3495.0
Chrome 67.0.3396.99
Safari 11.0.3
Do you know of any workarounds?
Prioritising WebAudioPlugin is probably suitable for most cases.
Otherwise enforcing a screen click, before any
play()call.But the error doesn't really cause any problems, so usually can be ignored.
Provide any extra details that will help us fix your issue:
Demo here:
https://codepen.io/anon/pen/mjmWyb
Opening in Chrome or Safari will fail to play the audio, and the error will show up in the JS Console.
Changing to
WebAudioPluginmakes it work (click the screen to stop the sound).It could be patched with the promise check method:
https://developers.google.com/web/updates/2016/03/play-returns-promise
Then maybe integrated with any WebAudio unlocking stuff.