//
//  AudioRecorderPlayerAppDelegate.m
//  AudioRecorderPlayer
//
//  Created by Chris Adamson on 5/17/09.
//  Copyright Subsequently and Furthermore, Inc. 2009. All rights reserved.
//
//
//  Licensed with the Apache 2.0 License
//  http://apache.org/licenses/LICENSE-2.0
//


#import "AudioRecorderPlayerAppDelegate.h"
#import <AVFoundation/AVFoundation.h>

@implementation AudioRecorderPlayerAppDelegate

@synthesize window;
@synthesize tabBarController;


- (void)applicationDidFinishLaunching:(UIApplication *)application {
    
	// declare audio category
//START:code.AudioRecorderPlayerAppDelegate.audiocategory
	AVAudioSession *audioSession = [AVAudioSession sharedInstance];
	NSError *audioSessionError = nil;
	[audioSession setCategory: AVAudioSessionCategoryPlayAndRecord
						error: &audioSessionError];
	if (audioSessionError)
		NSLog (@"Error setting audio category: %@",
			   [audioSessionError localizedDescription]);
//END:code.AudioRecorderPlayerAppDelegate.audiocategory
//START:code.AudioRecorderPlayerAppDelegate.audiosessionactive
	[audioSession setActive:YES error:&audioSessionError];
//END:code.AudioRecorderPlayerAppDelegate.audiosessionactive
	if (audioSessionError)
		NSLog (@"Error activating audio session: %@",
			   [audioSessionError localizedDescription]);
	
    // Add the tab bar controller's current view as a subview of the window
    [window addSubview:tabBarController.view];
}


- (void)applicationWillTerminate:(UIApplication *)application {
	NSLog (@"applicationWillTerminate!");
}

/*
// Optional UITabBarControllerDelegate method
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
}
*/

/*
// Optional UITabBarControllerDelegate method
- (void)tabBarController:(UITabBarController *)tabBarController didEndCustomizingViewControllers:(NSArray *)viewControllers changed:(BOOL)changed {
}
*/


- (void)dealloc {
    [tabBarController release];
    [window release];
    [super dealloc];
}

@end

