faimin / AudioSessionManager

This iOS module routes audio output depending on device availability using the following priorities: bluetooth, wired headset, speaker. It also notifies interested listeners of audio change events (optional).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

image

AudioSessionManager

Overview

This simple module routes audio depending on device availability using the following priorities: bluetooth, wired headset, speaker.

It also notifies interested listeners of audio change events (optional).

Requirements

The only requirement to use this module is an ARC-based iOS 6+ project.

Documentation

Initialization

AudioSessionManager is a singleton which can be initialized with a single statement:

// Initialize the audio session...
[[AudioSessionManager sharedInstance] startAndPostNotifications:YES];

Notifications

Two notifications are posted by this library if enabled:

  • kAudioSessionManagerDevicesAvailableChangedNotification - the list of devices (returned by the availableAudioDevices property) has changed
  • kAudioSessionManagerAudioDeviceChangedNotification - the current audio device (returned by the audioDevice property) has changed

Checking the current audio route

NSLog(@"audioRoute is %@", [AudioSessionManager sharedInstance].audioRoute);

Configuring the audio session

Configuring the device for input:

if (![[AudioSessionManager sharedInstance] changeMode:kAudioSessionManagerMode_Record]) {
    // .... handle error ...
}

and output:

if (![[AudioSessionManager sharedInstance] changeMode:kAudioSessionManagerMode_Playback]) {
    // .... handle error ...
}

About

This iOS module routes audio output depending on device availability using the following priorities: bluetooth, wired headset, speaker. It also notifies interested listeners of audio change events (optional).


Languages

Language:Objective-C 100.0%