我正在尝试创建一个 mp3 流媒体,但我失败得很惨:-)
我有以下内容AudioTrackStreamer
:
protected override void OnBeginStreaming(AudioTrack track, AudioStreamer streamer)
{
//TODO: Set the SetSource property of streamer to a MSS source
HttpWebRequest req = (HttpWebRequest)WebRequest.Create("https://api.soundcloud.com/tracks/85085126/stream?consumer_key=db840ada2477a93d5fdbcc96a46b37c1");
req.ContentType = "application/octet-stream";
try
{
req.BeginGetRequestStream((callback) =>
{
HttpWebRequest request = (HttpWebRequest)callback.AsyncState;
Stream stream = request.EndGetRequestStream(callback);
Mp3MediaStreamSource src = new Mp3MediaStreamSource(stream, 1000);
streamer.SetSource(src);
NotifyComplete();
}, req);
}
catch { }
它失败了,并收到ProtocolIViolationException
以下消息:
[Arg_InvalidOperationException]
Arguments:
Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=4.0.50829.0&File=mscorlib.dll&Key=Arg_InvalidOperationException
该文件的 url 是我在谷歌搜索免费音乐时发现的,如果你打开它,你可以下载一个 mp3 文件......所以来源应该是合法的?