2012年7月27日 星期五

How to play sound file in Objective C


NSString *newAudioFile = [[NSBundle mainBundle] pathForResource:@"t5"  ofType:@"wav"];
    NSError *error;
    
    AVAudioPlayer  player=  [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:newAudioFile] error:&error];
    
    [player setDelegate:self];
    
    [player prepareToPlay];
    
    [player play];

沒有留言:

張貼留言