播放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);

 

}

原文地址:https://www.cnblogs.com/zhujin/p/4907290.html