Hi everyone, I am new to this so please bear with me.
I have made a simple soundboard app, with a mainview and a flipside. The sounds are on the mainview, all works fine in the simulator, but when I download app to my device, everything except the sounds work!?
Hi everyone, I am new to this so please bear with me.
I have made a simple soundboard app, with a mainview and a flipside. The sounds are on the mainview, all works fine in the simulator, but when I download app to my device, everything except the sounds work!?
I have placed this code in the mainviewcontroller.m
The code I used in mainviewcontroller.h was : - (IBAction)playSound: (id)sender;
As I said before, it all works fine in the simulator but not on the device! Can anybody help me please??
SteveJames
If anyone can help, I can always show you guys more code if this helps?
Could be a lot of things, a quick checklist than I remember a colleague telling me about:
1. Preallocate the sound before you use it. Apparently you shouldn't initialize the sound right before you use it as the devices are slower than the Mac running the simulator.
2. File types. Is it .wav .aiff .caf?
3. Frequency/size/length/coding can all play a part as well.
Could be a lot of things, a quick checklist than I remember a colleague telling me about:
1. Preallocate the sound before you use it. Apparently you shouldn't initialize the sound right before you use it as the devices are slower than the Mac running the simulator.
2. File types. Is it .wav .aiff .caf?
3. Frequency/size/length/coding can all play a part as well.
Let me know if that helps.
Hi there, I have tried .wav .aiff and .caf,
The lengths of the sounds are only 3-4 seconds each, what do you mean by pre-allocate?
could it be the same problem ppl have with images? having the file in the project point to a location on the mac, but then it never gets copied to device? how did u add it to ur project?
Hi there, I have tried .wav .aiff and .caf,
The lengths of the sounds are only 3-4 seconds each, what do you mean by pre-allocate?
Try moving the AudioServicesCreateSystemSoundID to viewDidLoad. So when you call play system sound later it has fully processed the audio file by then. I believe this is what he meant by pre-allocate.
The only other thing I could think of is to make sure the filename is the correct case as I believe the device is case sensitive?
could it be the same problem ppl have with images? having the file in the project point to a location on the mac, but then it never gets copied to device? how did u add it to ur project?
I dragged the sound file from my desktop into the app folder, then opened the app folder and dragged the sound file into my project. Is that the correct way of adding a sound? I have also added sound files by right clicking (cntrl + Click) on the project name - add files - existing files and located the sound file that way .
Try moving the AudioServicesCreateSystemSoundID to viewDidLoad. So when you call play system sound later it has fully processed the audio file by then. I believe this is what he meant by pre-allocate.
The only other thing I could think of is to make sure the filename is the correct case as I believe the device is case sensitive?
Hi there, please bear with me, when you say move the AudioServicesCreateSystemSoundID to ViewDidLoad, do you mean type in ViewDidLoad to replace AudioServicesCreateSystemSoundId?
Hi there, please bear with me, when you say move the AudioServicesCreateSystemSoundID to ViewDidLoad, do you mean type in ViewDidLoad to replace AudioServicesCreateSystemSoundId?
Sorry if Im being a dumbass?
SteveJames
I am recommending you first call AudioServicesCreateSystemSoundId in the method viewDidLoad.
Then later on in your method you can call AudioServicesPlaySystemSound making sure you pass it the correct soundID you created in viewDidLoad. Does that makes sense?
Of course I cannot guarantee that this would solve the problem though.
I am recommending you first call AudioServicesCreateSystemSoundId in the method viewDidLoad.
Then later on in your method you can call AudioServicesPlaySystemSound making sure you pass it the correct soundID you created in viewDidLoad. Does that makes sense?
Of course I cannot guarantee that this would solve the problem though.
No Im so sorry, it doesnt make sense to me.. can you type the code how it should look?
It's pretty tough to viewDidLoad in a forum post. If you look in your documentation for "View Controller Programming Guide for iOS", the section on Custom ViewControllers explains what code goes in what method, including viewDidLoad. Have a look and let us know what you come up with.