Gamua / Sparrow-Framework

The Open Source Game Engine for iOS
http://www.sparrow-framework.org
Other
294 stars 83 forks source link

SPAudioEngine Mute Behavior #52

Open ronyeh opened 8 years ago

ronyeh commented 8 years ago

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

racarone commented 8 years ago

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.

ronyeh commented 8 years ago

Thanks Robert. I think that is a great solution! On Jan 30, 2016 5:18 AM, "Robert Carone" notifications@github.com 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 .

PrimaryFeather commented 8 years ago

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!!

ronyeh commented 8 years ago

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.

PrimaryFeather commented 8 years ago

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

ronyeh commented 8 years ago

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 notifications@github.com 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 .

PrimaryFeather commented 8 years ago

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: