访问流缓冲区 HttpWebRequest

7
我正在尝试在Windows Phone 7应用程序中流式传输收音机,为此我正在使用ManagedMediaHelpers。使用HttpWebRequest获取连续流可以工作,但由于连续流,它不会调用回调Url。
如何在没有回调Url的情况下访问流?在其他帖子中,有人说我需要使用反射,但有人知道如何实现吗?这是我的代码:
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);
    });
}

1
直播电台流的ContentLength是什么? - AnthonyWJones
同意!从调试中我看到这个值是-1...有什么想法或提示吗?谢谢回复! - Tepes Lucian
1个回答

1

我在AudioStreamer代理中做了几乎相同的事情,但是经过一段时间后,stream.Read会永远冻结。你遇到过这种问题吗? - Alex Sorokoletov
我没有。随意开另一个问题来涵盖这个问题。 - Den
我会的,但现在我不确定为什么它不起作用 - 是内存问题吗(不是),垃圾回收(不是)还是HttpWebRequest的特定问题(不知道)。 感谢您的回答,Den。 - Alex Sorokoletov

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接