I am trying to implement Shoutcast streams for my MediaElement through a MediaStreamSource. Here is the code with some basics. Using the ReadData method, I can load raw audio data (MP3 samples), my question is how to set the stream to MediaStreamSource. Thus, it does not work (it compiles and there are no errors in the MediaFailed event, but I can not hear any sound). Maybe I should implement all this in my custom ShoutcastMediaStreamSource? There are no problems with the fixed stream, only with the non-fixed one. Can anyone give me some advice?
In WP7 there is no way to set "useUnsafeHeaderParsing", so I can not get the HTTP headers with shoutcast metadata - only the source data. In ShoutcastMediaStreamSource, I implemented some ManagedMediaHelpers code.
thanks
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e) { HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://radiozetmp3-02.eurozet.pl:8400/;"); request.Method = "GET"; request.Headers["Icy-MetaData"] = "1"; request.UserAgent = "WinampMPEG/5.09"; request.AllowReadStreamBuffering = false; request.BeginGetResponse(new AsyncCallback(RequestComplete), request); allDone.WaitOne(); ShoutcastMediaStreamSource smss = new ShoutcastMediaStreamSource(stream); player.SetSource(smss); // MediaElement player.Play(); } public void RequestComplete(IAsyncResult r) { HttpWebRequest request = (HttpWebRequest)r.AsyncState; HttpWebResponse response = request.EndGetResponse(r) as HttpWebResponse; stream = response.GetResponseStream(); IAsyncResult res = stream.BeginRead(buffer, 0, buffer.Length, callback, null); allDone.Set(); } public void ReadData(IAsyncResult r) { int bytes = stream.EndRead(r); if (bytes == 0) { Debug.WriteLine("No bytes readed"); } else { Debug.WriteLine("readed: " + buffer.Length.ToString()); stream.BeginRead(buffer, 0, buffer.Length, callback, buffer); } }
windows-phone-7 shoutcast mediastreamsource
Krazz88
source share