AVFoundation.AVAudioSession Class
Coordinates an audio playback or capture session.

See Also: AVAudioSession Members

Syntax

[Foundation.Register("AVAudioSession", true)]
public class AVAudioSession : Foundation.NSObject

Remarks

Application developers should use the singleton object retrieved by AVAudioSession.SharedInstance.

Because the audio hardware of an iOS device is shared between all apps, audio settings can only be "preferred" (see SetPreferred* methods) and the application developer must account for use-cases where these preferences are overridden.

The interaction of an app with other apps and system services is determined by your audio category. You can use the AVAudioSession.SetCategory method to set this

You should also control the Mode (using AVAudioSession.SetMode to describe how your application will use audio.

As is common in AV Foundation, many methods in AVFoundation.AVAudioSession are asynchronous and properties may take some time to reflect their final status. Application developers should be familiar with asynchronous programming techniques.

The AVFoundation.AVAudioSession, like the AVFoundation.AVCaptureSession and AVFoundation.AVAssetExportSession is a coordinating object between some number of AVAudioSession.InputDataSources and AVAudioSession.OutputDataSources.

You can register to a few notifications that are posted by the audio system, by using the convenience methods in AVFoundation.AVAudioSession.Notifications.

C# Example

void Setup ()
{
	AVAudioSession.SharedInstance ().Init ();
	NSError error;
	if (!AVAudioSession.SharedInstance ().SetCategory (AVAudioSession.CategoryPlayback, out error)) {
		ReportError (error);
		return;
	}
	AVAudioSession.Notifications.ObserveInterruption (ToneInterruptionListener);
	
	if (!AVAudioSession.SharedInstance ().SetActive (true, out error)) {
		ReportError (error);
		return;
	}
	
	void ToneInterruptionListener (object sender, AVAudioSessionInterruptionEventArgs interruptArgs)
	{
		//
	}
}

Related content

Requirements

Namespace: AVFoundation
Assembly: Xamarin.iOS (in Xamarin.iOS.dll)
Assembly Versions: 0.0.0.0