Posted By

oppey on 05/23/11


Tagged


Versions (?)

avAudioPlayer任意のサウンドを再生するメソッド


 / Published in: Objective C
 

  1. -(void)playSoundWithURL:(NSURL*)fileURL{
  2.  
  3. NSError* error = nil;
  4. AVAudioPlayer* player = [[AVAudioPlayer alloc]initWithContentsOfURL:fileURL error:&error];
  5. if(error){
  6. NSLog(@"error = %@", error);
  7. NSLog(@"[error code] = %d",[error code]);
  8. return;
  9.  
  10. }
  11.  
  12. player.delegate = self;
  13. [player play];
  14.  
  15. }
  16.  
  17. -(void)audioPlayerDidFinishPlaying:(AVAudioPlayer*)player successfully:(BOOL)flag{
  18. [player release];
  19. }

Report this snippet  

You need to login to post a comment.