#import "TalkingDemoViewController.h"
@implementation TalkingDemoViewController
// Implement viewDidLoad to do additiona l setup after loading the view, typically from a nib.
- (void)viewDidLoad {
if (player) {
[player release];
}
NSString *soundPath=[[NSBundle mainBundle] pathForResource:@"intro" ofType:@"caf"];
NSURL *soundUrl=[[NSURL alloc] initFileURLWithPath:soundPath];
player=[[AVAudioPlayer alloc] initWithContentsOfURL:soundUrl error:nil];
[player prepareToPlay];
[soundUrl release];
[super viewDidLoad];
}
-(IBAction)sayTalking:(id)sender
{
NSLog(@"播放声音");
[player play];
}
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn’t have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren’t in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[player release];
[super dealloc];
}
@end