- Home /
 
               Question by 
               haydenjameslee · Jan 07, 2015 at 12:20 AM · 
                audioaudiosourcestreamingradio  
              
 
              Live audio streaming through Audio Source
My goal is to listen to an online radio stream in Unity (such as http://149.13.0.80/nrj.ogg) through an Audio Source. I've seen similar attempts posted before in this forum from a few years back but none seem to have worked out (most notably: http://forum.unity3d.com/threads/endless-audio-radio-streaming-in-unity.100564/).
The following code is how I've attempted it so far. This worked for streaming files stored on a server but not for live streams. I've commented out the www.progress > 0.2 conditional due to noticing that www.progress always resulted in 0 when I tried the livestream.
Does anybody have any insight into how to achieve this? Have there been any updates since that post linked above?
 public class StreamAudio : MonoBehaviour {
 
     public string url = "http://149.13.0.80/nrj.ogg";
     private WWW www;
 
     // Use this for initialization
     void Start () {
         www = new WWW(url);
         audio.clip = www.GetAudioClip(true, true, AudioType.OGGVORBIS);
     }
 
     public void Update ()
     {
         if (audio.clip != null && !audio.isPlaying && audio.clip.isReadyToPlay)// && www.progress > 0.2)
         {
             Debug.Log("play");
             audio.Play();
         }
         else if (www.progress <= 0.2)
         {
             Debug.Log(www.progress);
         }
     }
 }
 
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                