WP7 Shoutcast with MediaStreamSource

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); } } 
+6
windows-phone-7 shoutcast mediastreamsource
source share
2 answers

You need to develop your own MediaStreamSource.

You can find the prototype of the one I developed for one of my projects here: https://skydrive.live.com/redir.aspx?cid=eb0868f2135b874c&resid=EB0868F2135B874C!1037&parid=EB0868F2135B874C!169&authkey=!AGSYfVV

+2
source share

Try version = 2 in code. Now it works for me after changing one line of code

0
source share

All Articles