Hey Guys,
I’ve got an .ogg vorbis stream being loaded in Unity. It worked perfect until the 2.6 update, but now just doesn’t work at all and doesn’t return any errors to say why.
www=WWW("http://stream2.youseeradio.nl:8000/kartoffel.ogg");
audio.clip=www.audioClip;
yield WaitForSeconds(1);
audio.Play();
The above stream url is a random one which is always online. Can anyone help out?
Thanks!
Luke B
Edit: The sample code in the Script reference doesn’t do what it’s suppost to either. (Unity - Scripting API: WWW.audioClip)
It likely still works you are just not waiting long enough.
With 2.6, there was a thread priority property introduced which by default is not set to “ugly high” (which likely was its value before), as such downloading takes longer.
you can enforce the fastest possible download by altering the background thread priority again
Thanks for your reply!
I’ve tried using:
[url]www.threadPriority=ThreadPriority.Normal;[/url]
Straight after the WWW call, but that still doesn’t do anything. I also left it loading for a good 10 minutes and still had no luck. (before it started almost instantly).
ThreadPriority.High; keeps complaining about “res!=0” and still doesn’t work (theres no variable called res anywhere in the script). Is there anyway I can revert back to the old WWW class? - it was much better (and miles faster too) for what I do with it.
Update - All ThreadPriority class things aren’t working at all and are simply returning ‘res != 0’. Another great update by the unity team :?. Does anyone know what’s happening?
First, you should wait for audio.clip.isReadyToPlay before playing, to ensure that enough of the clip has been downloaded to enable playback.
Second, the clip url in your code sample doesn’t work, as the server never responds. Replacing it with another clip works.
This code works for me in 2.6:
www=WWW("http://upload.wikimedia.org/wikipedia/commons/a/a9/Tromboon-sample.ogg");
audio.clip=www.audioClip;
while(!audio.clip.isReadyToPlay)
yield WaitForSeconds(1);
audio.Play();
Hey - Thanks for your comment!
The above address is a streaming ogg (such as a live radio - one that doesn’t have a fixed length), so .isReadyToPlay is never called. The above code worked perfectly well in 2.5 (with that URL - it still works if it is tried out in a java stream reader). I’ve tried swapping the trombone file URL for a few different streams (such as “http://genesis.quasared.net:8888/lq.ogg”) but still with no luck. The annoying thing is this was a really, really, really important feature so I can’t just leave it out!
edit - Just found this post on the unity answers page: http://answers.unity3d.com/questions/750/stream-an-ogg-radio
(Major problem!!)
Never mind - I’ve came up with a way around this problem that seems to work even better than before 
Would you mind sharing with us how you done it? 