Posted By

takezou621 on 02/23/11


Tagged


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

athanhcong
Tintenklecks


Use System Sound Services


 / Published in: Objective C
 

  1. -(void)playSystemSound:(NSURL*)fileURL{
  2. SystemSoundID systemSoundID;
  3. OSStatus err;
  4.  
  5. err = AudioServicesCreateSystemSoundID((CFURLRef) fileURL,
  6. &systemSoundID);
  7.  
  8. if(err){
  9. NSLog(@"AudioServicesCreateSystemSoundID err = %d",err);
  10. return;
  11. }
  12.  
  13. // systemSoundCompletionProcFunctionはサウンド再生完了時に呼び出されるコールバック関数
  14. AudioServicesAddSystemSoundCompletion(systemSoundID,
  15. NULL,
  16. NULL,
  17. systemSoundCompletionProcFunction,
  18. NULL);
  19. // コールバック関数を削除
  20. //AudioServicesRemoveSystemSoundCompletion(systemSoundID);
  21.  
  22. // 再生開始
  23. AudioServicesPlaySystemSound(systemSoundID);
  24.  
  25. }

Report this snippet  

You need to login to post a comment.