streaming audio clipping with unity 3.X

While using unity2.6, we had this problem where the audio sound clip would cut out mid-way through playing towards the end of the clip. After upgrading to unity3.X we noticed this continued to happen. Is there any solution / workaround with the new version of unity?

Thanks.

(better code formatting...)

private IEnumerator PlayEffect( GameObject effect )
{ 
   while( !effect.audio.clip.isReadyToPlay ) 
   { 
      yield return( 1 ); 
   } 

   effect.audio.Play(); 
   yield return( new WaitForSeconds( effect.audio.clip.length ) ); 

   while( effect.audio.isPlaying ) 
   { 
      yield return( 1 ); 
   } 
   DestroyImmediate( effect.audio.clip ); 
   DestroyImmediate( effect ); 
}

Everything checks out with me too. In fact, I programmed something not-to-different and it worked fine.

Perhaps the issue is in your audio file? Unity might have troubles importing it off the net.

DISCLAIMER: These .ogg URLs are provided by the Xiph Open Source Community. http://www.vorbis.com/music/Epoq-Lepidoptera.ogg <-- Recommended. Starts up fast, loud audio. http://www.vorbis.com/music/Hydrate-Kenny_Beltrey.ogg <-- Shortest one http://www.vorbis.com/music/Lumme-Badloop.ogg http://www.vorbis.com/music/Mists_of_Time-4T.ogg http://www.vorbis.com/music/The_Abyss-4T.ogg

Source: http://www.vorbis.com/music/

I hope this helps. -- Flynn

Seems in 3.2 streaming does not work at all for OGG files: once you call WWW.audioClip, you've just got the samples for whatever OGG is so-far downloaded (not much when isReadyToPlay first becomes true!).

The best I've been able to do is this horrible hack (basically reconvert from OGG once the bit that was downloaded is almost finished playing):

var url = "http://www.vorbis.com/music/Epoq-Lepidoptera.ogg";

function Start () {
    var www = new WWW(url);
    audio.clip = www.audioClip;
    while (!www.isDone) {
        yield WaitForSeconds(1);
        if (audio.time > audio.clip.length-2) {
            audio.clip = www.audioClip;
        }
    }
}

function Update () {
    if(!audio.isPlaying && audio.clip.isReadyToPlay)
        audio.Play();
}