I'm using WWW Unity class to get songs from S3 Bucket.
The issue is this, when I'm loading one song, the streaming works great, I'm getting a big enough buffer and able to play a song easily with AudioSource Clip.
The problem starts when I try to call the function twich, witch actually means, I have the need to download two songs at the same time. Let me notice that if I try to hold the second function, still I get an error ( The error is a "Red" error, but without any data about the error).
Function:
private IEnumerator startSongStreaming(int playerIndex,User user)
{
string url = user.getCurrentGamePerformacePath ();
WWW www = new WWW (url);
AudioSource audioSource = GameObject.FindGameObjectsWithTag ("PlayerResultsAudio")[playerIndex].GetComponent<AudioSource>();
AudioClip myAudioClip = audioSource.clip;
Debug.Log (playerIndex + " :" + www.progress);
while (www.progress < .1f) {
Debug.Log ("Streaming WWW PLAYER INDEX: " + playerIndex + " " + www.progress);
yield return null;
}
myAudioClip = www.audioClip;
Debug.Log (playerIndex + " CHECKTHIS:" + www.progress);
while (!(myAudioClip.isReadyToPlay)) {
Debug.Log ("IS READY TO PLAY PLAYER INDEX: " + playerIndex + " " + www.progress);
yield return null;
}
//Debug.Log ("TESTME: " + myAudioClip.isReadyToPlay);
audioSource.clip = www.GetAudioClip(false, true, AudioType.WAV);
Button listen = GameObject.FindGameObjectsWithTag ("PlayerResultsListenBtn") [playerIndex].GetComponent<Button> ();
listen.interactable = true;
}
I have no issues with the prefabs and getting the GameObjects, it works great with the funciton that function that calls this function.
Anyhow the debug.logs return a good streaming for one of the indexs, and sets streaming to 1 on the other ( like it's finished, but it never really started ). so I get 0 and streaming ( object will work and play ) and 1 and 1 streaming ( like streaming is completed but an unknowen error and cant play the audio ).
I know it's a head to understand question, Thank ahead.