- Home /
Unity 3 iPhone Audio from Documents folder with www.audioclip
Hola,
Is it still true that Unity's built-in audio player can't play audio from the /Documents folder in iOS?
So I'd still have to use AVAudioPlayer?
ty
Answer by ibyte · Nov 24, 2010 at 05:22 AM
Julian,
I am loading ogg-vorbis formated files from the documents folder on my iPad and iPhone. I did this so my Audio engineer would be able to update sounds in my game while in development so I would not have to do a new build each time he wanted to change the audio clips.
Contrary to what the Unity web site (documentation) states, ogg-vorbis files seem to work just fine on iDevices when loaded via WWW. It is wav that cannot be loaded via WWW.
Answer by Wozik · Sep 29, 2010 at 12:16 PM
Here's a code snippet for you
var www : WWW = new WWW("file://" + docPath + localPath);
yield www;
if(www.error == null){
print("Loaded local bundle - instantiating :: " + www.assetBundle.mainAsset.name);
Instantiate(www.assetBundle.mainAsset, Vector3(0, 0, 1.5), Quaternion.identity);
print("INSTANTIATED FROM LOCAL");
}
Wouldn't that require an pre-made .unity3d file at localpath? I'm talking about .wav files created in the app and saved in /Documents/ Like I say I've tried www.audioclip.
Answer by mytoltoly · Dec 02, 2010 at 11:09 PM
how did you load ogg files from documents folder?
this is what i tried.
.........
www = new WWW("file:///var/mobile/Applications/6832F66D-DC62-40A1-A026-2436F6479CE1/Documents/song.ogg"); if (www == null) return null;
return www.oggVorbis;
...........
Answer by Mantas-Puida · Sep 27, 2010 at 12:27 PM
As far I know it should work.
I've got it working with an external call to AVAudioPlayer on the iPad but all my attempts failed when using www.audioclip. The iPhone docs never even mention playing external audio on iPhone.
Your answer
Follow this Question
Related Questions
WWW.GetAudioClip hardware decoding? ( on iphone and android ) 1 Answer
best way to show iphone purchased assets 0 Answers
Large memory footprint increase when assigning a GUITexture from a WWW Object on iPad 1 Answer
WWW.LoadFromCacheOrDownload not working 1 Answer
Unity 3 Iphone Internet connection 1 Answer