Sparrow-Framework icon indicating copy to clipboard operation
Sparrow-Framework copied to clipboard

SPAudioEngine Mute Behavior

Open ronyeh opened this issue 9 years ago • 7 comments

I added a note on Line 67 of this commit: https://github.com/Gamua/Sparrow-Framework/commit/bf413cfa7b21d6279aed241c2558b070dea7a066

Recently I upgraded my Tiny Piano app to use Sparrow 2.X's SPAudioEngine. However, behavior has changed from 1.X. I used to use SPAudioSessionCategory_MediaPlayback, because it would continue the audio even if the device was muted. This was important as sometimes people would leave their ringer on mute and then leave a 1-star review for my app, saying that it's dumb that the audio doesn't work in a piano app.

However, SPAudioSessionCategory_MediaPlayback no longer overrides the mute switch.

See the comment here: https://github.com/Gamua/Sparrow-Framework/blob/master/sparrow/src/Classes/SPAudioEngine.h#L41

The comment above suggests that the old functionality is desired, and that we should instead add a new enum to the SPAudioSessionCategory to allow users to choose AVAudioSessionCategoryMultiRoute.

In summary, I think the mappings should be like this:

SPAudioSessionCategory_MediaPlayback => AVAudioSessionCategoryPlayback SPAudioSessionCategory_MultiRoute => AVAudioSessionCategoryMultiRoute

ronyeh avatar Jan 29 '16 20:01 ronyeh

Ya this is definitely a mistype! Thanks for the catch!

I've deprecated SPAudioSessionCategory and added a startWithCategory: method to SPAudioEngine that uses AVAudioSessionCategorys directly. The old version will select the correct category, but I think using the categories directly just makes more sense now.

racarone avatar Jan 30 '16 13:01 racarone

Thanks Robert. I think that is a great solution! On Jan 30, 2016 5:18 AM, "Robert Carone" [email protected] wrote:

Ya this is definitely a mistype! Thanks for the catch!

I've updated the branch and deprecated SPAudioSessionCategory and added a startWithCategory: method to SPAudioEngine that uses AVAudioSessionCategory directly. The old version will now select the correct category now, but I think using the categories directly just makes more sense now.

— Reply to this email directly or view it on GitHub https://github.com/Gamua/Sparrow-Framework/issues/52#issuecomment-177173912 .

ronyeh avatar Jan 30 '16 16:01 ronyeh

Thanks for the fix, Robert! Ron, sorry for the bad reviews — but it's great to see you're still a loyal Sparrow user! :smile: I hope that Tiny Piano and it's siblings are still working great for you!!

PrimaryFeather avatar Feb 02 '16 07:02 PrimaryFeather

No worries! I found the regression before shipping the new update. :-)

I'm not actually using Sparrow 2.X yet, since Tiny Piano is 4 yrs old and I haven't bothered to upgrade. I just borrowed some stuff from the new SPAudioEngine and noticed that it wasn't working the same way.

ronyeh avatar Feb 02 '16 09:02 ronyeh

Makes sense! Never change a running system — still one of the most important truths in our field! :wink:

PrimaryFeather avatar Feb 02 '16 09:02 PrimaryFeather

It's truly a testament to the robustness of your code, that it still works years down the road!

On Tue, Feb 2, 2016 at 1:50 AM, Daniel Sperl [email protected] wrote:

Makes sense! Never change a running system — still one of the most important truths in our field! [image: :wink:]

— Reply to this email directly or view it on GitHub https://github.com/Gamua/Sparrow-Framework/issues/52#issuecomment-178480812 .

ronyeh avatar Feb 02 '16 09:02 ronyeh

The principle behind that is simple: use as few iOS APIs as possible! :stuck_out_tongue_closed_eyes:

All jokes aside, whenever one my apps stopped working in a new iOS version, it was because one of the iOS APIs were changed or introduced a bug. I can't blame Apple, because there is a lot going on in the iOS ecosystem — but as an app developer, you're definitely on the safer side by not using their APIs too much. :wink:

PrimaryFeather avatar Feb 04 '16 17:02 PrimaryFeather