OGG stream

Hi,

I am trying to play an OGG stream in my application but I can’t manage to do it.
I would like to use not a “finished” ogg file but a “streaming” file. In my case an internet radio stream.

I have used the following sample :
var url : String;
function Start ()
{
www=new WWW(url);
audio.clip=www.audioClip;
}
function Update ()
{
if(!audio.isPlaying audio.clip.isReadyToPlay)
{

  • Debug.Log(“audio play”);*
  • audio.Play();*
    }
    }

I try with the following stream address : http://stream2.youseeradio.nl:8000/kartoffel.ogg

I appears that I never go to “audio.Play()”
I have an audio source component in my game object.

Any ideas?

Thanks,
Gildas

did you get your stream working…i have a similar problem

I believe this is because it’s a continous stream of data. Normally Unity will report the download progress (and probably base AudioClip.isReadyToPlay off of that) because it knows the total size. It doesn’t seem to update progress or clip length in any way for that continous stream.

I got it to work in a hacky kind of way, but I’m guessing it’s going to be gross if the stream buffer runs out for any reason and there’s not really a way to tell if it has (that I know of):

var url : String;
var ready : boolean;

function Start ()
{
	www=new WWW(url);
	audio.clip=www.audioClip;
	ready = false;
	
	yield new WaitForSeconds(10);
	
	ready = true;
}

function Update ()
{
	Debug.Log(audio.clip.length);
	if (!audio.isPlaying  ready)
	{
		Debug.Log("audio play");
		audio.Play();
	}
}

Also, I believe this leaks memory since Unity is sticking the stream as it comes in into the audio clip. But it plays the music. :lol:

1 Like