- Home /
Audio stops playing while loading
Hi,
(Unity v 2.5 - C#)
i have a music manager that plays an audio (streamed using WWW object).
When new level loaded, audio stops playing even though it wasn't calling audio.Stop().
And, i tried 'DontDestroyOnLoad()' and also, 'LoadLevelAdditive()'. It did not work.
Using debug, i printed whether the music manger was destructed. It was not.
I also printed audio playback time (audio.time) in Update().
I noticed that the audio.time stay constant once the new level loaded (i.e: it does seem to stop playing), and audio.isPlaying is still true.
This was ogg file which reside in web server. I checked progress of downloading, and it downloaded all complete, and played it (all good for streaming). But, when new level is loaded, audio stops 'playing', but, the flag was still set to be playing, and, playback does not update.
Any idea?
Thanks in advance.
Answer by Jaap Kreijkamp · Dec 09, 2009 at 02:27 AM
Have you tried updating to Unity 2.6.1? Don't know if it solves your bug but it's always worth trying. You can also try having the audio added as asset to the project instead of streaming it.
Answer by Paul · Dec 09, 2009 at 10:18 PM
Thanks for answer.
It actually works on v2.6. It seems like a bug in v2.5.
Something is strange in unity audio library. There are what i found:
v2.5:
- when you stream ogg file (checking after isready as well as stream.isdone), audio.length returns zero, and isplaying is still true when the song is over. (this does not happen at v2.6)
v2.6:
accessing ogg file to get the length(orgVorbis) of the song sometimes crashes. But, it did not happen at v2.5 player.
Suddenly, i am getting doppler effect of the song played when my character moves left or right. In the UI (no chracter movement), i don't have this problem. This effect does not happen in v2.5.
ABOVE ALL,
I can fix all that based on what version of library EXCEPT this crazy doppler effect. I tried to set:
audio.velocityUpdateMode = AudioVelocityUpdateMode.Fixed;
at the update loop, but, it did not help. Rolloff Factor was set to zero for audio source.
I am not sure what causes this strange sound effect.
Thanks.
You're welcome, but to make sure others see that question is answered you should click on the V sign next to my (or your own) answer :-) About the doppler effect, in 2.6.x stereo sounds can be positioned in 3D, I guess to prevent this you could connect the audiosource to the camera.
Actually, audio source is following the camera (which is listener). But, the doppler is still there. It almost like velocity takes account where i can see the effect of camera moving.
It does not make sense to have this effect when the source and listener is moving together.
Your answer
![](https://koobas.hobune.stream/wayback/20220613180911im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Loading music for initial scene loading takes a very long time 1 Answer
Audio skipping 2 Answers
Adaptive audio / channel switching 0 Answers
c# bandvol 0 Answers