Stream an OGG radio

I have made a simple audio streaming test which worked very well on 2.5 and which doesn't work any more on 2.6.

Maybe a hint : when I use url of a .ogg file it work perfectly, with a ogg radio (that I can read with firefox 3.5) it doesn't work at all.

Here is what i'am doing :

public class TestRadio : MonoBehaviour {

public AudioSource audio;

void Start () 
{
    WWW wwwStream = new WWW("http://giss.tv:8000/fmr.ogg"); // Doesn't work
    //  WWW wwwStream = new WWW("http://ia301106.us.archive.org/2/items/abird2005-02-10/abird2005-02-10t02.ogg"); // Work fine

    if (wwwStream.error == null)
    {
        audio.clip = wwwStream.audioClip;
    }
}

void Update () {
    if (!audio.isPlaying && audio.clip.isReadyToPlay)
    {
        audio.Play();
    }
    else
    {
        Debug.Log("waiting - isplaying : " + audio.isPlaying + " isreadyToPlay : " + audio.clip.isReadyToPlay);
    }
}

}

The log always report isplaying = false and isreadytoplay = false in the case of the radio

Is there something I make wrong ?

Thanks

Jrme

Unity does not support endless ogg streams. If this happened to work in 2.5, then it was unintended - however, even there, it would probably cause trouble, as Unity would try to download the stream into memory, which would eventually make it run out of memory.

In 2.6, the audio engine has been replaced - we went from OpenAL to FMOD, which has probably resulted in this change. If support for ogg streams is important to you, I suggest you request it as a new feature on feedback.unity3d.com.

Hum ok I see ... bad news

So I have another question : It is the same for Video stream with ogg Theora ?

That means we cannot stream radio

i came across the same problem, and after nearly 2 hours, i finally solved it. The reason is that you wanna to play the audio before its completely downloaded, you should call audio.Play function like this:

    string bkgrdMusicPath = Application.dataPath + "/Rockburst_YC/Resources/bkgrdMusic.ogg";
    _download = new WWW(bkgrdMusicPath);
    while (_download.audioClip.isReadyToPlay == false)//NOTE:the while loop is very important!
    {
        yield return _download;
    }
    
    _bkgrdMusic = _download.GetAudioClip(false, false);
   _bkgrdMusic.name = "downloadMusic";
    
    if (_bkgrdMusic == null)
    {
        _bBkgrdMusicOn = false;
        UnityEngine.Debug.Log("无法找到背景音乐, 请检查Rockburst_YC/Resources/文件夹下是否有bkgrdMusic.ogg音频文件!");
    }
    else
    {            
        audio.clip = _bkgrdMusic;
        audio.enabled = true;
        audio.loop = true;
        print(_bkgrdMusic.isReadyToPlay.ToString());
        if (_bkgrdMusic.isReadyToPlay)
        {
            audio.Play();
        }
    }

And a wrong version like this:

  string bkgrdMusicPath = Application.dataPath + "/Rockburst_YC/Resources/bkgrdMusic.ogg";
    _download = new WWW(bkgrdMusicPath);
    yield return _download;//No while loop at all! the audio may not be completely downloaded, that's the reason!
    
    _bkgrdMusic = _download.GetAudioClip(false, false);
   _bkgrdMusic.name = "downloadMusic";
    
    if (_bkgrdMusic == null)
    {
        _bBkgrdMusicOn = false;
        UnityEngine.Debug.Log("无法找到背景音乐, 请检查Rockburst_YC/Resources/文件夹下是否有bkgrdMusic.ogg音频文件!");
    }
    else
    {            
        audio.clip = _bkgrdMusic;
        audio.enabled = true;
        audio.loop = true;
        print(_bkgrdMusic.isReadyToPlay.ToString());
        if (_bkgrdMusic.isReadyToPlay)
        {
            audio.Play();
        }
    }