播放wav聲音格式

1.

#import <AudioToolbox/AudioToolbox.h>

 

2.聲明 成員变量 

    SystemSoundID soundID;

 

 

3.播放

- (void)playSoundWith:(int)index

{

    

    if (soundID ) {

        AudioServicesDisposeSystemSoundID(soundID);

    }

    NSString *path = [[NSBundlemainBundle] pathForResource:[NSStringstringWithFormat:@"ring%d",index] ofType:@"wav"];

    AudioServicesCreateSystemSoundID((__bridgeCFURLRef)[NSURLfileURLWithPath:path], &soundID);

    

    AudioServicesPlaySystemSound(soundID);

 

 

}

 

posted on 2015-10-24 18:07  助金  阅读(142)  评论(0编辑  收藏  举报