Return to Snippet

Revision: 41959
at February 25, 2011 10:29 by takezou621


Initial Code
- (void) playSoundWithURL: (NSURL*) fileURL{
	NSError	*error = nil;
	AVAudioPlayer *player = 
		[[AVAudioPlayer alloc] initWithContentsOfURL: fileURL
											error: &error];
	if(error){
		NSLog(@"error = %@",error);
		NSLog(@"[error code] = %d",[error code]);
		return;
	}
	player.delegate = self;
	[player play];
}

-(void) audioPlayerDidFinishPlaying: (AVAudioPlayer *)player successfully:(BOOL) flag{

	[player release];
}


// 呼び出し
-(void) viewDidLoad{
	NSString *path = [[NSBundle mainBundle] pathForResource:@"pad"
												ofType:@"aif"];
	NSURL *fileURL = [NSURL fileURLWithPath:path];
	[self playSoundWithURL:fileURL];
}

Initial URL


Initial Description


Initial Title
AVFoundation サンプル

Initial Tags


Initial Language
Objective C