- Home /
How long should a streaming OGG audio take to start playing?
Hello - I'm having a strange problem using the WWW class and streaming a music file using .ogg format. The problem is that the clip doesn't signal the isReadyToPlay flag until several seconds have passed. If I print out the value of 'progress' on the WWW object it goes from 0.0 to 1.0 during this time. Only when it hits 1.0 does isReadyToPlay get set to true and then I can play the clip fine.
The music .ogg is around 5.5 megs big and it is taking roughly 13 seconds for isReadyToPlay to signal true. I'm downloading it on a fast internet connection. When I try FTPing the file from the website to my computer it takes about 7 seconds total.
So I'm a bit confused. I was hopeful that the .ogg would start playing a couple seconds after I issue the WWW request, but that doesn't seem to be the case at all. It seems like it is downloading the whole file before setting isReadyToPlay to true. There may be additional time to decompress the file in memory, but I'm not sure...the docs are somewhat sparse.
Can anyone shed some light on this for me? Thanks.
Code below:
void Start() { privateWww = new WWW(url); musicClip = privateWww.audioClip; }
void Update() { if (musicClip!=null && musicClip.isReadyToPlay && audioSource.isPlaying==false) { audioSource.clip=musicClip; audioSource.Play(); musicClip=null; } }
(edit: formatted code; please use the 1010 button to format code snippets and make your questions for readable, thanks!)
Looks like you're doing it right, the docs indicate that isReadyToPlay should be true once enough data has been buffered, and I see you're pretty much copying the example code. I would normally fire the WWW request from a coroutine, but I don't see why that would make a difference.
Just to add in, test with a really small sound file... It'll make testing easier. And as yoyo said, it should work.
A bit of clarification would help here: Is the 'progress' property indicating how much of the total clip has finished downloading, or is it indicating how much has downloading before isReadyToPlay is set to true? It would seem that it should be the former, but Unity is acting like its the latter.
Update for those with similar problems: It looks as if the slow ogg loading is only in the Editor. Strea$$anonymous$$g from the webplayer is just as quick as it should be.
Your answer
Follow this Question
Related Questions
Ogg Stream Live Video 0 Answers
Best practice: URL address for storing streamed music files 1 Answer
Trying to stream .ogg file in Mac OSX results in error without description 0 Answers
Play a ogg file in Unity3d says “Streaming of 'ogg' on this platform is not supported” 1 Answer
How can I convert a video to .ogg format and have it play from a web server? 7 Answers