I think I got it. setActive can be called with a second argument and it seems to make all the difference. In all the tutorials I have seen, none made use of it so I didn't know it existed yet - until I read the docs ;)
*try theSession.setActive(true, with:[.notifyOthersOnDeactivation])* that tells the Music app to unpause when my audio is done. I put this stuff into a function which seems to be working. Eric On Thu, Aug 24, 2017 at 8:52 AM Eric E. Dolecki <edole...@gmail.com> wrote: > Quick question. > > Am I supposed to set the category, then set a different category while my > audio plays, then when complete go back to the original category? Is that > how I should approach - or are you supposed to set the category one time? > > Eric > > On Fri, Aug 18, 2017 at 3:02 PM Eric E. Dolecki <edole...@gmail.com> > wrote: > >> Where I am at currently. >> >> let audioSession = AVAudioSession.sharedInstance() >> do { >> try >> audioSession.setCategory(AVAudioSessionCategoryPlayAndRecord, with: >> [.duckOthers, .allowBluetoothA2DP, .allowAirPlay, .defaultToSpeaker]) >> try audioSession.setActive(true) >> } catch { >> print("Error. \(error.localizedDescription)") >> } >> >> This doesn't stop Apple Music. This allows me to record audio in the app. >> This ducks Apple Music when I set the category. The defaultToSpeaker allows >> my recorded audio to sound full volume instead of sounding like 0.6 of >> volume (which is weird). The ducking DOES NOT duck Apple Music as needed, >> it seems to duck the audio while my app is running. It also seems to >> degrade the audio somewhat coming to my headphones. >> >> I haven't been banging on iOS 11 beta yet (been holding off). I should >> look to see if they added anything here or not. >> >> Have a great weekend! >> >> On Fri, Aug 18, 2017 at 2:04 PM Eric E. Dolecki <edole...@gmail.com> >> wrote: >> >>> I moved stuff to AppDelegate and it seems a little better. However, when >>> my audio plays, I get Apple Music to duck, and it doesn't come back up in >>> volume. I got a notification during this, and when IT'S audio ping was done >>> playing, Apple Music returned to normal volume. >>> >>> Still playing around... >>> >>> On Fri, Aug 18, 2017 at 1:58 PM Alex Zavatone <z...@mac.com> wrote: >>> >>>> There are 4 options you the audio category mode that you can test. >>>> >>>> Apple’s docs suck badly on this topic. I suggest you create the 4 >>>> possible test cases and try them out. >>>> >>>> Also note that one of them will support the silent/mute switch. This >>>> is an item that is worth testing to know what you are getting. >>>> >>>> Cheers, >>>> Alex Zavatone >>>> >>>> > On Aug 18, 2017, at 12:55 PM, Quincey Morris < >>>> quinceymor...@rivergatesoftware.com> wrote: >>>> > >>>> > On Aug 18, 2017, at 10:47 , Eric E. Dolecki <edole...@gmail.com> >>>> wrote: >>>> >> >>>> >> I would assume that the audio would come back up. And wouldn't think >>>> my app would pause Apple Music when it starts up... >>>> > >>>> > Unless someone else jumps in with the answer, I’d say it’s TSI time! >>>> > >>>> > _______________________________________________ >>>> > >>>> > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) >>>> > >>>> > Please do not post admin requests or moderator comments to the list. >>>> > Contact the moderators at cocoa-dev-admins(at)lists.apple.com >>>> > >>>> > Help/Unsubscribe/Update your Subscription: >>>> > https://lists.apple.com/mailman/options/cocoa-dev/zav%40mac.com >>>> > >>>> > This email sent to z...@mac.com >>>> >>>> _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com