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

Inconsistent behaviour between HTML5 and Web Audio when mute button is activated on iOS #753

Closed
sedubois opened this issue Apr 28, 2017 · 19 comments
Labels

Comments

@sedubois
Copy link

I was running the "Basic Functions" demo on https://howlerjs.com and observed that the "Run web audio tests" does not produce any sound on my iPhone (iOS 10.3.1).

I'd love to understand why, considering that http:https://caniuse.com/#feat=audio-api shows Web Audio API should work on iOS Safari?

@NathanLawrence
Copy link

I'm on 10.3.1 and having no issues whatsoever. Which phone model are you using?

@sedubois
Copy link
Author

@NathanLawrence iPhone 6 using safari browser. You?

@tocalivros
Copy link

tocalivros commented May 17, 2017

Well I also can not play the iPhone (6 and 6s) using iOS 10 and the latest version (10.3.2).

What I realized is that the problem is that in iOS AutoStart does not work and does not work the function goes standalone, but if you create a simple button to play, it's works just push the button that works.

Is this a problem for Howler.js or iOS? Detail did the tests in both Safari and Chorme the result was the same.

Edit: I tested the same simple code in two Android and it worked (the code is similar to the basic so I put the bugger and small things).

@sedubois
Copy link
Author

Okay if it's just because of auto start then it's more of an iOS feature, but I guess example should be updated to have a play button as you suggested.

Anyway currently I'm trying to skip howler and the web audio API entirely, instead using HTML5 audio, as I only need basic playback features, but need good cross browser support.

@NathanLawrence
Copy link

This is very odd. I wonder why I'm having trouble recreating this. It might be worth trying to build some sort of test profiler. Did you find a workaround with Howler, or did you have to give up?

@sedubois
Copy link
Author

@NathanLawrence I gave up Howler because I realised I don't need it so far, just using plain HTML5 player.

@nerris
Copy link

nerris commented May 25, 2017

Hi. I'm experiencing similar issues. With Safari iOS 10.3.2 and iPhone 6S, there is no sound for me. It only works if I use it with the html5 option enabled and playing the sound inmediately after an onclick event. Nothing related with AudioContext is working. The 'Basic functions test' available at Howler website it's not working also.

UPDATE: Sorry, i just restarted the device and started working.

@ghost
Copy link

ghost commented Jun 17, 2017

did anyone make it work with cordova ios 10.3.2?

@goldfire
Copy link
Owner

goldfire commented Jul 6, 2017

I'm unable to reproduce this issue on 10.3.2 or 10.3.3. Is anyone still having this issue, and if so, can you post steps to reproduce?

@sedubois
Copy link
Author

sedubois commented Jul 6, 2017

@goldfire i haven't used this since, but just tried again as in the OP without issues this time. It sounds silly, but it might be because my device was muted. The radio player demo disregards the iPhone's mute button, but the web audio demo actually takes it into account.

My apologies for the confusion, feel free to close. Still curious why the mute button sometimes works and sometimes doesn't.

@Stenerson
Copy link
Contributor

Anecdotally, I’ve also had people report issues to my Howler based repo on iOS because their devices were muted and they didn’t realize. It has caused some confusion and hair pulling in the past for us as well.

@kane-mason
Copy link

+1 for this issue. Its not really an issue but more of an inconsistency. When my iPhone is muted and i load into my game, all the sounds seem to play. But when a new Howl is added and a sound played from it, it starts playing and then cuts off promptly. Might have something to do with 'unlocking' sounds because its a new Howl? I understand the device is on mute, but you would expect either all the sounds to play, or none of them. Using iPhone6S iOS 10.3.3

@patadv
Copy link

patadv commented Jul 31, 2017

I am experiencing the AutoStart errors on my iphone 6 running 10.3.2. However, as soon as I manually push a button that triggers a sound (htm5 or web audio), the AutoStart functionality works as expected from then onwards.

I'm also experiencing the problem with not hearing sound when my iphone is muted (silent mode). I can experience this problem even with the demos on the howler front page. While listening to the audio sprites demo, as soon as I flick the switch to turn the phone off silent, audio immediately comes alive. This is only a problem using web audio and sound is not muted when using html5.

@goldfire
Copy link
Owner

Unless I'm misunderstanding, this is the expected behavior. If the physical mute switch is on, then you should not hear any sound until you switch it un-muted. Closing for now, but will re-open if I was understanding the issue incorrectly or different information is provided.

@goldfire goldfire added the ios label Aug 18, 2017
@kanemason
Copy link

@goldfire the thing is on iOS when your device's mute switch is on, sounds do play! They are just less reliable, some will play, some will not. I am not sure if this is something that can be handled within howler or not, but ideally I would just expect some consistency in the sense that when your device is set to mute, you either hear all sounds, or none of them, not an unpleasant mixed result.

@goldfire
Copy link
Owner

@kanemason Are you referring to when HTML5 audio and Web Audio are mixed? HTML5 Audio seems to play regardless of the mute status, and I'm unaware of a way to fix this (if someone knows of a way I'd be happy to get it integrated). I've been unable to reproduce a scenario where this doesn't work consistently with Web Audio to this point.

@kanemason
Copy link

@goldfire we are using both html5 audio (for background music) and web audio. And we have multiple audio sprites loaded and playing at a time.

@sedubois sedubois changed the title No sound with Web audio API on iOS Safari Inconsistent behaviour between HTML5 and Web Audio when mute button is activated on iOS Aug 19, 2017
@swevans
Copy link

swevans commented Oct 21, 2017

@goldfire There is a way to make web audio play w/ the mute switch set to silent. If you play a short, silent <audio> sound the web audio will switch from muted to unmuted and play the same way as HTML audio. That's the only way I have found to make it consistent. IMO web audio should NOT be tied to the ringer volume and should be have the same as HTML audio.

I posted an example of code that makes web audio play like <audio> here:
https://stackoverflow.com/a/46839941/2103488

I actually have some information in addition to that answer-
When you play <audio> the ios lock screen shows an audio control widget. This is undesirable since the audio playback can't really be controlled by those controls. This can be hidden by first loading an empty mp3 data url in the <audio> tag, then on first user interaction you set the source to a short, silent base64 encoded mp3 and play it back. Boom fixed. LMK if you want some more info.

@scottanderson42
Copy link
Contributor

@goldfire We've been having this issue with Howler on iOS ourselves. The problem turned out to be that HTML5 Audio will unlock upon user interaction, but not if the actual play happens in the loadeddata or seeked events even if the sound load is started via user interaction.

#1008 enables HTML5 Audio unlocking similar to the WebAudio unlock.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

10 participants