WWW.oggVorbis Vs. WWW.audioClip - Webplayer playback problem

Hi,

I have a problem where after I load a WWW object in ogg format WWW.audioClip is null. However, WWW.oggVorbis is not null and I can retreive and play the audio file properly. I believe the reason WWW.audioClip is null is that the ogg file doesn’t have an “.ogg” extension although it is in .ogg format.

I would like to be able to use WWW.audioClip for two reasons:

  1. WWW.oggVorbis is deprecated and unity suggests to use WWW.audioClip
  2. On the webplayer, and only on a few machines, the audio doesn’t play. I suspect using WWW.audioClip could fix the issue (Perhaps this was why WWW.oggVorbis was deprecated?)

My question is if anybody has run into a similar issue and found a fix for it. I am also wondering why Unity checks the extension of a file instead of the content of a file to populate WWW.audioClip.

Hi Nima,

it’s difficult to say something precise about this without full code to reproduce the bug, but I think you are right about the extension being the factor that makes it work in one of the cases, but this should be a problem with the oggVorbis property too.
There is a newer way to use streamed audio via the GetAudioClip function instead of the audioClip property that you mentioned: http://docs.unity3d.com/Documentation/ScriptReference/WWW.GetAudioClip.html
Actually, when you use the audioClip property, behind the scenes it actually calls WWW.GetAudioClip(true, false, AudioType.UNKNOWN) which explains why it needs to wait for the whole sound being loaded into memory (second argument = false) and why it uses the extension to determine the format (third argument = AudioType.UNKNOWN).
So since in your case the file doesn’t have an extension to identify the format from, you will need to specify it via the last optional parameter.

Jan

Hi Jan,

Thanks for your reply. I am on Unity 3.4 now which doesn’t have the optional parameter for audio type. I will try updating to 3.5 and see if that fixes the problem.

So definitely using WWW.GetAudioClip with the 3rd parameter AudioType.oggVorbis (under Unity 3.5) makes it so that it recognizes the file as an AudioClip. I am still not sure if this fixes a more general problem with audio not playing on certain computers. I will update the thread when I can confirm the answer.

Update: I can confirm now that this fixes the problem I was seeing with audio not playing only on certain computers. I am trying to get a work around to it with Unity 3.4 by adding the .ogg extension to all my audio files.