Hi all,
I have 2 AudioClips and 1 AudioSource. I want to be able to switch the clip at certain intervals.
What i’m doing is:
- Fading out the source volume.
- Stopping the Source playing.
- setting the new clip.
- Starting it playing.
- Turning up the volume.
Everything is working within the editor and the sounds are changing correctly BUT, when I build to iPhone, the app is freezing when the clips are changed.
The clips are background music (about 1 minute long each), originally WAV’s which i convert to AAC within iTunes.
Has anyone had this happen too?
Sorry, for not posting code but i’m away from my dev machine at the moment (i can post later if needed).
Side Note: I’m not checking in code that the music has stopped or is ready to play etc, if this could be causing the freeze. Also, within XCode Analyzer my app is using about 26MB of memory if this could also be the problem.
Best Regards,
Matt.
Well i’m no further forward with this after a day of tinkering (and drinking strong coffee).
Searching the Unity Forum has surfaced a few threads on sound crashes, but most seem to favour memory issues. ie:
http://forum.unity3d.com/viewtopic.php?t=25943&start=0&postdays=0&postorder=asc&highlight=sound+crash
Like i said above, my app is levelling out at about 26MB in the activity monitor, which according to a few threads, seems to be the magical maximum number.
I’m considering ‘Going to Plan B’ over this and rethinking the sound… but will hold off incase anyone has a final insight into my issue. So any guesses (or telling me i’m doing something overly stupid with changing the AudioClips) would be greatly received.
Best Regards,
Matt.
Well i’ve solved it (i hope)…
Incase anyone is interested :roll: I think i was being a numpty! It seems like I wasn’t leaving enough time for the Clip to be switched before playing again and the whole shibang was going the way of the sky!!
I’ve stuck a couple of yields between the clip changes and plays etc and now no crashes. 
i guess i should have tried this before posting (lesson learned)… i’ll now retreat back under my rock and you wont hear from me again…
Matt.