Hi guys!
I’m having some kind of problem when I’m trying to retrieve the length of an audioclip.
I’m loading the audio from the StreamingAssets folder, and the audio does play, but for some reason the audioClip.lenght is returning 0. Am I doing something wrong, or is this some kind of bug?
I need to know the length of the audio file so I can sync it with some subtitles and other stuff.
Any kind of help would be appreciated.
Thanks!
using (UnityWebRequest www = UnityWebRequest.GetAudioClip(audioPath, AudioType.MPEG))
{
yield return www.Send();
if (www.isError)
{
DebugController.OutputLogError("[AudioController] Error " + www.error + " Url: " + www.url);
}
else
{
DebugController.OutputLog("[AudioController] Success! WWW - " + www.url, true);
AudioClip audioClip = DownloadHandlerAudioClip.GetContent(www);
Debug.Log("[AudioController] Sound Played audioClip.length " + audioClip.length + " Name " + audioClip.name);
audioSource.clip = audioClip;
audioSource.Play();
}
}