Skip to content

Conversation

@jusephe
Copy link
Contributor

@jusephe jusephe commented Oct 23, 2020

Howler.js 2.2.0 doesn't play WAV files in Safari 14, because this method is returning empty string (i.e. false) in Safari 14: audioTest.canPlayType('audio/wav; codecs="1"'). I created an issue for it: #1414
So I added another option without specifying codecs attribute which fix this. Here is demo to test it: https://stackblitz.com/edit/js-bvgnv8?file=index.js

ogg: !!audioTest.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, ''),
oga: !!audioTest.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, ''),
wav: !!audioTest.canPlayType('audio/wav; codecs="1"').replace(/^no$/, ''),
wav: !!(audioTest.canPlayType('audio/wav; codecs="1"') || audioTest.canPlayType('audio/wav')).replace(/^no$/, ''),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it is a real scenario, but what if

audioTest.canPlayType('audio/wav; codecs="1"') returns "no"

and

audioTest.canPlayType('audio/wav;') returns "maybe" ?

you still would get wav as an empty string ""

Maybe you can change it to:

wav: !!(audioTest.canPlayType('audio/wav; codecs="1"').replace(/^no$/, '') || audioTest.canPlayType('audio/wav').replace(/^no$/, ''))

jjhamshaw added a commit to jjhamshaw/useAudioPlayer that referenced this pull request Oct 28, 2020
E-Kuerschner pushed a commit to E-Kuerschner/useAudioPlayer that referenced this pull request Oct 28, 2020
* feat: include .wav file example

* fix: wav files not working in Safari (goldfire/howler.js#1415)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants