- Home /
WWW.getAudioClip() returning wrong length from one server but not another
The project has both a WebPlayer and iOS build. All text is narrated using audio files loaded from a media server. WebPlayer loads ogg files and iOS loads MP3 files.
There's a handful of clips that are coming in with extra silence added to the end of the track, but only when streaming MP3 and only from within Unity (both the Editor and on the device). If I enter the URL into a browser, it loads properly. One track is about 8 seconds long, but when I load the clip via the following script, the debug statement shows a length of over 16 seconds:
WWW www = new WWW(GetURL(source));
AudioClip clip = null;
yield return www;
if (www.error != null && www.error.Length > 0)
{
Debug.Log(www.error + "(" + source + ")");
}
else
{
#if UNITY_IPHONE
clip = www.GetAudioClip(false, false, AudioType.MPEG);
#else
clip = www.GetAudioClip(false, false, AudioType.OGGVORBIS);
#endif
while (clip != null && clip.isReadyToPlay == false)
yield return null;
Debug.Log("Length of " + source + " is " + clip.length);
}
Unfortunately, I can't provide a link to the audio files.
Has anyone experienced anything like this?
iam trying to load mp3 on iosdevice the same way you do but i get no sound aswell as no error message. do you here any sound on the device? in editor switched to ios platform everythings works normal.i tried mp3 lame and propritery fraunhofer codec with constant bitrate but nothing worked for me. do you here a sound on device?
concave: I do get sound to play on the device. Check your url in a browser. If the format is $$anonymous$$P3 and the extension is $$anonymous$$P3 and you're using AudioType.$$anonymous$$PEG, it should play. $$anonymous$$eep in $$anonymous$$d you have to yield until it's ready to play.
my audioclip never gets ready to play - the download from filesystem is successful - on www.bytes i get the right length of bytes but when i wait for isReadyToPlay after GetAudioClip it gets stuck in the loop without beeing null.