Windows Phone7上的ShoutCast的HttpWebRequest [英] HttpWebRequest for ShoutCast on Windows Phone7

查看:72
本文介绍了Windows Phone7上的ShoutCast的HttpWebRequest的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的Windows Phone 7应用中流式播放直播

I tring to stream shoutcast stream in my window phone 7 app

我像这样启动一个异步HttpWebRequest

I start an async HttpWebRequest like this

//Init Request

HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create("http://ACommonoShoutCastUrl:8000");

myHttpWebRequest.Headers["Icy-MetaData"] = "1";

myHttpWebRequest.UserAgent = "WinampMPEG/5.09";

myHttpWebRequest.AllowReadStreamBuffering = true;

//Call

 // Create an instance of the RequestState and assign the previous myHttpWebRequest object to its request field.  

RequestState myRequestState = new RequestState();

 myRequestState.request = myHttpWebRequest;

 // Start the asynchronous request.

 IAsyncResult result = (IAsyncResult)myHttpWebRequest.BeginGetResponse(new AsyncCallback(RespCallBack), myRequestState);

问题在于CallBack-> RespCallBack从未被调用...

The problem is that the CallBack->RespCallBack is never called...

此代码通常在其他环境中对我有效,但在电话上不起作用...

This code worked for me normally in other environments but not on the phone...

我也很讨厌使用似乎可以流数据的WebClient,

I tired also to use WebClient that seems to stream data,

这种情况下的问题是,由于无聊的广播流,它永远不会调用OpenReadCompleted结束

the problem in this case is that it never call the end OpenReadCompleted because of endelss shoutcast stream

感谢支持

任何帮助将不胜感激

推荐答案

SHOUTcast实现了自己的协议,因此您不能直接访问和播放它.您可以使用 DownloadStringAsync (您将需要 WebClient 实例)以下载 PLS 文件并借助RegEx阅读URL.

SHOUTcast implements its own protocol so you can't directly access and play it. You can use DownloadStringAsync (you will need a WebClient instance for this) to download the PLS file and read the URL with the help of RegEx.

获取URL时,可以通过实现

When you get the URL, you can read the raw audio data by implementing MediaStreamSource and then use a MediaElement to play the contents.

您可以找到 MediaStreamSource 的示例实现

You can find a sample implementation of MediaStreamSource here.

这篇关于Windows Phone7上的ShoutCast的HttpWebRequest的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆