x


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

more ▼

asked Nov 25 '09 at 11:28 AM

Jerome gravatar image

Jerome
13 2 2 5

(comments are locked)
10|3000 characters needed characters left

4 answers: sort voted first

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 http://feedback.unity3d.com.

more ▼

answered Nov 25 '09 at 03:45 PM

jonas echterhoff gravatar image

jonas echterhoff ♦♦
9.7k 7 23 102

(comments are locked)
10|3000 characters needed characters left

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();
        }
    }
more ▼

answered Dec 13 '11 at 02:58 PM

Yanger_xy gravatar image

Yanger_xy
270 22 25 33

(comments are locked)
10|3000 characters needed characters left

That means we cannot stream radio

more ▼

answered Sep 01 '10 at 10:37 AM

rahul gravatar image

rahul
1

(comments are locked)
10|3000 characters needed characters left

Hum ok I see ... bad news

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

more ▼

answered Nov 26 '09 at 09:13 AM

Jerome gravatar image

Jerome
13 2 2 5

Yes, that should be the same thing.

Nov 26 '09 at 03:20 PM jonas echterhoff ♦♦
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1024

asked: Nov 25 '09 at 11:28 AM

Seen: 2880 times

Last Updated: Dec 13 '11 at 02:58 PM