I can’t get www streaming to work. Searched online for some ogg radio stations (since standalone doesn’t decode mp3).
I can see by the bandwidth consumed that Unity is downloading from the stream allright, but the isReadyToPlay flag never turns on, and none of the bytes downloaded are made available to me. If I even try to do a simple print (www.bytesDownloaded), Unity hangs and I have to force close it.
This is my testing code:
using UnityEngine;
using System.Collections;
public class ogg_radio : MonoBehaviour {
public string url1 = "http://149.13.0.80:80/radio1rock.ogg";
public string url2 = "http://ai-radio.org:8000/128.ogg";
void Update()
{
if (Input.GetKeyDown(KeyCode.F1)) this.Tune(this.url1);
if (Input.GetKeyDown(KeyCode.F2)) this.Tune(this.url2);
}
void Tune(string url)
{
this.StopAllCoroutines();
this.StartCoroutine(this.__Tune(url));
}
IEnumerator __Tune(string url)
{
var www = new WWW(url);
var clip = www.GetAudioClip (false, true, AudioType.OGGVORBIS);
while (!clip.isReadyToPlay) {
yield return null;
}
this.audio.clip = clip;
this.audio.Play ();
}
}