Streaming Video Missing Audio in Unity 2.6.1

Hello,
We’re streaming .ogg videos from our web server using WWW.movie, and everything was working fine with Unity 2.5. After upgrading to Unity 2.6.1, the movies still play OK, but with no audio.

We’ve got a script attached to a polySurface object which also has Mesh Renderer and Audio Source components. Yes, the Audio Source is enabled and volume is not 0.0 :slight_smile:

Its update has a section that looks something like this:

void Update()
{
  if ((www == null) || ![url]www.movie.isReadyToPlay[/url]) return;
  DebugLog("Now Playing " + folder + schedule[index].filename);
  DebugLog("Audio info: " +
    "channels " + [url]www.movie.audioClip.channels[/url] + ", " +
    "frequency " + [url]www.movie.audioClip.frequency[/url] + ", " +
    "hideFlags " + [url]www.movie.audioClip.hideFlags[/url] + ", " +
    "isReadyToPlay " + [url]www.movie.audioClip.isReadyToPlay[/url] + ", " +
    "length " + [url]www.movie.audioClip.length[/url] + ", " +
    "name " + [url]www.movie.audioClip.name[/url] + ", " +
    "samples " + [url]www.movie.audioClip.samples[/url] +
    "\n");
  renderer.material.mainTexture = (Texture)[url]www.movie;[/url]
  audio.clip = [url]www.movie.audioClip;[/url]
}

And the output looks something like:

VideoHandler: Now Playing [url]http://www.X.com/Y.ogg[/url]
VideoHandler: Audio info: channels 0, frequency 0, hideFlags 0, isReadyToPlay False, length -1, name , samples 0

So it looks like the audio clip portion of the movie just hasn’t been initialized yet. We tried changing the condition to:

  if ((www == null) || ![url]www.movie.isReadyToPlay[/url] || ![url]www.movie.audioClip.isReadyToPlay[/url]) return;

but the movie just never begins playing. Instead, after a while, Unity gets a fatal error:

Is there something additional we need to do to ensure both the audio and video are ready to stream? Could there be some problem with our .ogg files? Or is this just a bug new to Unity 2.6 that still needs to be resolved? Please help!

Ok, we figured it out. The WWW.movie scripting
documentation starts by assigning www.movie to a MovieTexture object and uses that rather than accessing www.movie repeatedly. It seems that assigning www.movie.audioClip directly to your audio.clip just doesn’t work for some reason. Pretty subtle difference. I still find it odd that the old code would work in Unity 2.5 but not 2.6.

void Update()
{
  MovieTexture movie = [url]www.movie;[/url]
  if (www == null || !movie.isReadyToPlay)
    return;  
  renderer.material.mainTexture = (Texture)movie;
  audio.clip = movie.audioClip;
}