- Home /
 
streaming local sound files on iOS
Hi,
My application/project will include sounds tracks, I would like to avoid to pre-load them into memory when the application starts. How can I 'streaming' them from a resources folder (StreamAssets folder ?) when I need them?
I was not able to find clear answers. Well I found that thread - http://forum.unity3d.com/threads/356...g-audio-player - but the link is broken and the thread is kinda old.
Any help is appreciated.
Thanks.
(not sure where the best place was I asked the same question on the forum - http://forum.unity3d.com/threads/169236-streaming-local-sound-files-on-iOS)
Answer by smallfly · Feb 23, 2013 at 07:19 PM
I have been able to make it work with WWW request
Here is my method:
     private IEnumerator loadAndPlayAudioClip() {
         string path = "file://"+Application.dataPath + "/Raw/Audio/";
         string fileName = "street-voices.wav";
 
         // Start a download of the given URL
         WWW request = new WWW(path + fileName);
 
         // Wait for download to complete
         yield return request;
 
         // use request.audio        
         AudioClip audioTrack = request.GetAudioClip(false, true);
         audio.clip = audioTrack;
         audio.Play();
     }
 
              Your answer
 
             Follow this Question
Related Questions
audio stream current length 1 Answer
Unity iPhone: Audio "stream from disc" memory usage 1 Answer
Export objects to a .3DS file at runtime 1 Answer
WWW class streaming high RAM usage 0 Answers
Streaming Audio in WebGL 1 Answer