Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access Stream Buffer HttpWebRequest

I'm trying to stream radio in a Windows Phone 7 app and for this I'm using ManagedMediaHelpers. The HttpWebRequest to get the continuous stream works but doesn't call the callback Url because of the continuous stream.

How do I access the stream without the help of the callback Url? On other posts some said O need to use reflection but does someone knows hot to implement it? Here is my code:

req = (HttpWebRequest) WebRequest.Create(
    "http://streamer-dtc-aa01.somafm.com:80/stream/1018");

// if this is false it will fire up the callback Url 
// but the mediastreamsource will throw an exception 
// saying the it needs to be true
req.AllowReadStreamBuffering = true; 

IAsyncResult result = req.BeginGetResponse(RequestComplete,null);

private void RequestComplete(IAsyncResult r)
{
    HttpWebResponse resp = req.EndGetResponse(r) as HttpWebResponse;
    Stream str = resp.GetResponseStream();

    mss = new Mp3MediaStreamSource(str, resp.ContentLength);
    Deployment.Current.Dispatcher.BeginInvoke(() => {
        this.me.Volume = 100;
        this.me.SetSource(mss);
    });
}
like image 795
Tepes Lucian Avatar asked Sep 02 '11 13:09

Tepes Lucian


1 Answers

Had the same issue, so here is how I solved it:

Getting bytes from continuous streams on Windows Phone 7

It might also be a problem with your URL - make sure that if you run the request outside the application, you are getting the necessary amount of data.

like image 75
Den Delimarsky Avatar answered Oct 05 '22 03:10

Den Delimarsky