Play a short sound in iOS

前端 未结 13 828
悲哀的现实
悲哀的现实 2020-11-27 10:23

I guess I could use AVAudioPlayer to play a sound, however, what I need is to just play a short sound and I don\'t need any loops or fine-grained control over t

13条回答
  •  一生所求
    2020-11-27 10:57

    Check out systemsound to play short audio file

    include audiotoolbox framework

    and create

    systemsoundid object

    NSString *soundPath =  [[NSBundle mainBundle] pathForResource:file ofType:@"aiff"];
    AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath: soundPath], &soundID);
    AudioServicesPlaySystemSound (soundID);
    

提交回复
热议问题