Hello. This could be a quick fix.
So I want to stream some audio. I copied and pasted the example to a script and changed the url, and it doesn’t play the audio.
I think I might be missing something but I don’t know what…
Code:
void Start()
{
StartCoroutine(GetAudioClip());
}
IEnumerator GetAudioClip()
{
Debug.Log("Step 1");
using (UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip("https://composerconnection.com:8106/stream", AudioType.MPEG))
{
Debug.Log("Before step 2");
((DownloadHandlerAudioClip)www.downloadHandler).streamAudio = true;
Debug.Log(www.result);
yield return www.SendWebRequest();
Debug.Log("After step 2");
if (www.result == UnityWebRequest.Result.ConnectionError)
{
Debug.Log(www.error);
}
else
{
Debug.Log("HIT");
AudioClip myClip = DownloadHandlerAudioClip.GetContent(www);
a.PlayOneShot(myClip);
Debug.Log("WOO");
}
}
}
So yeah. I’m unsure what the solution is but you guys might.