I’m having some trouble getting ogg’s to play on the iPhone. I can download them from a server and save them. But I cannot play them back, either directly from the server or from where I saved them. Both playing them from the stored location and playing them on the fly from the server work in the editor.
I can load textures in from the server or the stored location with no problems on the iPhone though. Any ideas?
url = "file://" + dirPath + "/testsong.ogg";
www = new WWW(url);
yield www;
var musicObject = new GameObject ("One shot audio");
musicObject.transform.position = transform.position;
music = musicObject.AddComponent (AudioSource);
music.clip = [url]www.oggVorbis;[/url]
music.volume = 1.0;
music.Play();
Unless things have changed, I believe ogg is not supported on the iPhone. I can only recommend you turn them into mp3s.
If I use mp3’s they will not play in the editor or on the iPhone.
music.clip.isReadyToPlay never returns true
Has anyone been able to play any kind of external audio from anywhere on the iPhone?
on the iphone you can only play mp3 (and on unity iphone 1.x m4a, but unity iphone 3 does not support them so don’t waste time converting to them. I guess that unity iphone 3 might potentially use fmod too, not only the desktop side and as m4a is an apple proprietary its “out”).
What it does in the editor should really be of your least interest, but if you are worried that much, consider having 2 files online and code present that if the code is executed in editor, goes to the ogg and otherwise mp3
So what you are saying is that this should work on iPhone:
url = "file://" + dirPath + "/testsong.mp3";
www = new WWW(url);
yield www;
var musicObject = new GameObject ("One shot audio");
musicObject.transform.position = transform.position;
music = musicObject.AddComponent (AudioSource);
music.clip = [url]www.audioClip;[/url]
music.volume = 1.0;
music.Play();
But it does not. And if get rid of the last line above and add something like this to the Update function isReadyToPlay always returns false.
if(!music.isPlaying){
if(music.clip.isReadyToPlay){
music.Play();
}
}
Indeed I don’t really care what happens in the editor, but I have been able to get neither ogg, or mp3 to work on the iPhone.
Any word if this is possible?
I’m seeing this thread too, which implies that it is possible, but without a confirmation. Has anyone gotten this to work?