I play a few short sounds on my iPad like this: Listen to short sound in iOS
I am using a caf file that I can successfully play from Finder. Now I have gone through quite a bit of trouble trying to achieve sound reproduction, and I'm curious what problems there may be that I do not seem to understand:
Option 1: When I create a SystemSoundID and then play it right away, I donโt hear anything on the device and the simulator.
Option 2: When I create an instance variable for SystemSoundID and initialize it in viewDidLoad , I can play the sound, but only on the iPad, not on the Simulator.
Option 3: Instead of using SystemSoundID I can also use AVAudioPlayer to play the .wav file, which then works on both iPad and Simulator, but here I need to create AVAudioPlayer in viewDidLoad otherwise I wonโt get any sound if I do it all in one time.
The best option currently looks like Option 3 , because it works on both the Simulator and the iPad, but since I need to initialize the Player first, I need an AVAudioPlayer instance for every other sound I want a game that doesn't seem to be very wise memory ...
Is there something Iโm missing and is it possible to play sounds on both platforms using the AudioToolbox framework (Option 1 and Option 2)
ios objective-c ipad audio audiotoolbox
Besi Apr 27 2018-12-12T00: 00Z
source share