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.

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.

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.