I start in this very confusing Objective-C game.
I would like to play a very short sound effect every time a certain button is pressed.
How can i do this?
Can I use an mp3 file? Or do I need to convert to wav?
You can use System Sound Services to play short sounds:
CFBundleRef mainBundle = CFBundleGetMainBundle(); CFURLRef soundFileURLRef = CFBundleCopyResourceURL(mainBundle, CFSTR("filename"), CFSTR("aiff"), NULL); SystemSoundID soundId; AudioServicesCreateSystemSoundID(soundFileURLRef, &soundId); AudioServicesPlaySystemSound(soundId); CFRelease(soundFileURLRef)
.caf, .aiff and .wav.
Not enough reputation to comment on @dstnbrkr's solution, so I will post it as an answer instead.
CFURLRef soundFileURLRef .
CFURLRef soundFileURLRef
CFRelease(soundFileURLRef) (AudioServicesPlaySystemSound(soundId);), Core Foundation.
CFRelease(soundFileURLRef)
AudioServicesPlaySystemSound(soundId);
Source: https://habr.com/ru/post/1733842/More articles:How to get the total horizontal width in Label, Button, TextArea or TextBox characters? - javascriptCut long text to fit width in pixels - javascriptDifference between concatenating id and html tag ie ul # nav vs #nav ul - htmlThe extension method has any restriction in C # - c #"Найти все ссылки" не работает в visual studio 2005 - visual-studio-2005Limit attachment of large files using Javascript - javaHow can I play sound in C #? - c #Using an international keyboard in an iPhone app - iosDisable Outlook Security Message Box - c #How to get a link to a node in the DOM tree in the console of the Google Chrome debugger - domAll Articles