Skip to content
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

fix wav support in Safari 14 #1415

Merged
merged 1 commit into from
Oct 24, 2020
Merged

fix wav support in Safari 14 #1415

merged 1 commit into from
Oct 24, 2020

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

@@ -273,7 +273,7 @@
opus: !!audioTest.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/, ''),
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