- Home /
 
Radio Streaming Unity 3.5
Hi, i was reading and looking for info about how to reproduce a radio streaming (.mp3) with C#. In this moment i need some help with an issue: The streaming is collected, but is played instantly and just can hear too much noise, then a little piece of the streaming is played and after this: silence. I was trying with corutines but i dont know exactly how to implement it: Here is the Code (WARNING: Working with streamings freezes the Mac/PC, Restart unity needed ):
 using UnityEngine;
 
 public class Streaming : MonoBehaviour {
     public WWW www;
     public string url ;
     
     public float timecount;
     public float starttime;
     public float finaltime;    
     public int sec;
     
     public bool flagPrecharged;
         
     // Use this for initialization
     void Start ()
     {        
         starttime = Time.time;
         
         url = "http://194.169.201.177:8085/liveM80.mp3";
         www = new WWW (url);
         
         audio.clip = www.GetAudioClip (false, true, AudioType.MPEG);
         //audio.clip = www.audioClip; // Doesnt work with streamings
 
     }
     
     // Update is called once per frame
     void Update ()
     {
         timecount = Time.time - starttime;
         sec = (int)(timecount % 60f);            
         
         if (!audio.isPlaying && audio.clip.isReadyToPlay) {
             finaltime = Time.time - starttime;
             audio.Play ();
             
             Debug.Log ("RUNNING: " + timecount + ", secs: " + sec);
         } else {
             Debug.Log ("NOT READY: " + "Progress: " + www.progress + ", secs: " + sec);    
         }
                             
     }
 }
 
               Thanks in advance,
Answer by DaveA · Nov 20, 2012 at 10:06 PM
If audio is playing, it would output "NOT READY.... " on every frame right? Which also does a stack-dump every frame. I'd get rid of that Debug.Log and see if that helps. Try using a GUIText or something like that to display messages if you need that.
Answer by Checho · Nov 21, 2012 at 04:12 PM
Thanks for the advice. I modified the code and off course I have a different way to debug with the GuiText, but the error is the exactly the same, nothing has changed.
Did you know something related with streaming that maybe I am doing wrong?, thanks
Your answer
 
             Follow this Question
Related Questions
A node in a childnode? 1 Answer
Live audio streaming through Audio Source 0 Answers
Screetching Sound While Walking? Why? 0 Answers
how to add option to buy ingame items on my unity game 0 Answers
Unity iPhone: Audio "stream from disc" memory usage 1 Answer