Note that there are some explanatory texts on larger screens.

plurals
  1. POWP7 Shoutcast with MediaStreamSource
    text
    copied!<p>I am trying to implement the Shoutcast streaming to my MediaElement via MediaStreamSource. Here is a code with some basics. With the ReadData method I can download raw audio data (MP3 samples), my question is how can I set the stream to the MediaStreamSource. In this way it doesn't work (it compiles and there are no errors on MediaFailed event but i can't hear any sound). Maybe should I implement all of these in my custom ShoutcastMediaStreamSource? There is no problem with fixed stream, just with non-fixed. Can somebody give me some advice?</p> <p>On the WP7 there is no possibility to set the "useUnsafeHeaderParsing" so I can't get http headers with shoutcast metadata - only raw data. In the ShoutcastMediaStreamSource i have implemented some code of ManagedMediaHelpers.</p> <p>Thanks</p> <pre><code> 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); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload