Playing system sound without importing your own

后端 未结 10 2179
情深已故
情深已故 2020-11-27 02:26

Is it possible to play already existing system sounds without importing your own?

10条回答
  •  我在风中等你
    2020-11-27 03:29

    This code plays apple system sound "Tock.aiff"..I believe you can play different system sounds using this

    NSString *path = [[NSBundle bundleWithIdentifier:@"com.apple.UIKit"] pathForResource:@"Tock" ofType:@"aiff"];
    SystemSoundID soundID;
    AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:path], &soundID);
    AudioServicesPlaySystemSound(soundID);
    AudioServicesDisposeSystemSoundID(soundID);
    

    See this thread

    Apple's documentation on System sounds

    https://developer.apple.com/documentation/audiotoolbox/system_sound_services

提交回复
热议问题