Bug 32671 - Events on AVAudioSession do not work and should be removed as AVAudioSesionDelegate is deprecated since iOS 6
Summary: Events on AVAudioSession do not work and should be removed as AVAudioSesionDe...
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: XI 8.10
Hardware: PC Mac OS
: Normal normal
Target Milestone: 8.13 (C6 alpha)
Assignee: Bugzilla
Depends on:
Reported: 2015-07-31 14:10 UTC by Jon Goldberger [MSFT]
Modified: 2015-07-31 14:38 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Jon Goldberger [MSFT] 2015-07-31 14:10:43 UTC
## Description

Subscribing to the event AVAudioSessoin.OuputChannelsChanged does not fire when headphones are plugged in or removed. Since the AVAudioSessionDelegate is deprecated since iOS 6, the event should not even exist to Miguel. I assume this is true for all of the events on AVAudioSession then. 

See Apple's docs: https://developer.apple.com/library/ios/documentation/AVFoundation/Reference/AVAudioSessionDelegate_ProtocolReference/

I don't think I need to provide steps to reproduce other than to try setting up an AVAudioSession and subscribing to the OutputChannels changed event and note that the event does not fire when headphones are plugged in or removed. 

Also Miguel already on Slack noted that this event does not do anything. 

For anyone else running into this, the way to get audio session events is to use NSNotifications, e.g. to get the event when headphones are plugged in or unplugged, observe the AVAudioSession.RouteChangeNotification:

>var audioSession = AVAudioSession.SharedInstance();
>NSNotificationCenter nc = NSNotificationCenter.DefaultCenter;
>nc.AddObserver(this, new ObjCRuntime.Selector("routeChanged:"), AVAudioSession.RouteChangeNotification, null);
>Then implement the RouteChanged method to handle the notification:
>public void RouteChanged(NSNotification notification)
>      Console.WriteLine("Route changed:\nReason: {0}\nPrevious Route: {1}", 
>          notification.UserInfo.ValueForKey(new NSString("AVAudioSessionRouteChangeReasonKey")),
>          notification.UserInfo.ValueForKey(new NSString("AVAudioSessionRouteChangePreviousRouteKey"))
>       );
Comment 1 Sebastien Pouliot 2015-07-31 14:36:40 UTC
They was already marked [Obsolete] (by Miguel last night) and they will, eventually*, be removed.

* that's an API breakage and can affect already compiled assemblies, e.g. components, that have references (even if not directly using the members/notifications). As such the removal won't happen before we're forced to to an API break release (e.g. like unified was).
Comment 2 Sebastien Pouliot 2015-07-31 14:38:07 UTC
for reference (and QA validation)
maccore/master 4a9aba19e535e57531613284e4d536ed0c355d69