从 ConnectStream 异步写入 MemoryStream
我正在编写一个 MP3 播放器,可以从互联网上播放歌曲。问题是我无法在 ConnectStream 中使用 Seek() 方法。 我想也许可以在流式传输期间将 ConnectStream 异步复制到 MemoryStream 并使用 MemoryStream 的 Seek() 方法。 有谁知道这可能吗?或者也许有人知道如何以其他方式做到这一点? 谢谢。
I am writting a mp3 player which streams songs from Internet. The problem is that I can't use Seek() method in ConnectStream.
I thinking maybe it's possible to copy ConnectStream to MemoryStream asynchronously during streaming and use MemoryStream's Seek() method.
Does anyone has idea is it possible? Or maybe someone knows other way how to do this?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您希望允许用户在歌曲中来回查找,那么您可能走对了路。分配 MemoryStream,并使用 CopyTo 方法(假设您使用的是 .NET 4),如下所示:
如果您想同时下载和查找(例如 YouTube 视频),则需要使用稍微复杂的技术。我不会详细描述它们,而是请您参考来源:
http: //msdn.microsoft.com/en-us/magazine/cc337900.aspx
If you are looking to allow the user to seek back and forth through the song, you are probably on the right track. Allocate a MemoryStream, and use the CopyTo method (assuming that you are on .NET 4), as follows:
If you want to download and seek at the same time (like a youtube video for instance), you need to use slightly more complex techniques. Rather than describe them in detail, I'll just refer you to the source:
http://msdn.microsoft.com/en-us/magazine/cc337900.aspx
是的,这可以通过 System.IO.MemoryStream 实现。然后,您可以在本地内存中缓冲一些流。考虑使用 System.IO.BufferedStream
Yes, this is possible with System.IO.MemoryStream. You are then buffering some of the stream in the local memory. Consider using System.IO.BufferedStream