Created
July 2, 2015 23:59
-
-
Save mingsai/7f76c03cbbe1d6f7c53d to your computer and use it in GitHub Desktop.
An AVAudioSession delegate to manage audio session events and an extension to the AVAudioSession to manage convenient setup for various audio profiles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// MNGAVAudioSessionExtensions.swift | |
// | |
// | |
// Created by Tommie Carter on 6/30/15. | |
// Copyright © 2015 MING Technology. All rights reserved. | |
// | |
import AVFoundation | |
class MNGAVAudioSessionExtensions: NSObject, AVAudioSessionDelegate { | |
func beginInterruption() { | |
// | |
} | |
func endInterruption() { | |
// | |
} | |
func endInterruptionWithFlags(flags: Int) { | |
// | |
} | |
func inputIsAvailableChanged(isInputAvailable: Bool) { | |
// | |
} | |
} | |
extension AVAudioSession { | |
func configureSpokenRecordingSession (){ | |
do { | |
try self.setCategory(AVAudioSessionCategoryPlayAndRecord) | |
print ("session category set to \(self.category)") | |
} catch let e as NSError { | |
print("could not set session category") | |
print(e.localizedDescription) | |
} | |
do { | |
try self.setActive(true) | |
print ("session active status set to \(self)") | |
} catch let e as NSError { | |
print("could not make session active") | |
print(e.localizedDescription) | |
} | |
} | |
func configureSpokenPlaybackSession () { | |
do { | |
try self.setCategory(AVAudioSessionCategoryPlayback) | |
} catch let e as NSError { | |
print(e.localizedDescription) | |
print("could not set session category") | |
} | |
do { | |
try self.setActive(true) | |
} catch let e as NSError { | |
print(e.localizedDescription) | |
print("could not make session active") | |
} | |
} | |
func configureMusicPlaybackSession() { | |
} | |
func configureMusicRecordingSession() { | |
} | |
func audioVolumeChangeListenerCallback () { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment