如何从ftp播放视频? .网 [英] how play video from ftp with? .net

查看:580
本文介绍了如何从ftp播放视频? .网的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用.net从ftp播放视频?

how play video from ftp with .net?

推荐答案

快速答案是:不好的主意. FTP无法保证所需的帧速率.但是,实际上,可用的媒体流解决方案也不能保证流畅观看所需的不间断数据供应,因此您可以尝试.实际上,没有什么可以阻止您将整个媒体文件从FTP下载到临时位置并进行播放.要使用FTP,您需要使用类System.Net.FtpWebRequest:
http://msdn.microsoft.com/en-us/library/system.net. ftpwebrequest.aspx [ ^ ].

查看此页末尾的代码示例.通常,您正在使用System.Net.FtpWebResponse.GetResponseStringSystem.Net.FtpWebResponse获取的Stream中读取数据,并按块读取数据,这很适合您的目的.请参阅:
http://msdn.microsoft.com/en-us/library/system.net. ftpwebresponse.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/system. net.ftpwebresponse.getresponsestream.aspx [ ^ ].

即使您可以即时读取数据,但以将数据馈送到播放器组件的方式流式传输数据是另一个大问题(再次考虑将整个文件下载到一个临时位置并将文件位置馈送到播放器) .如果您真的想以即时流式传输的方式解决问题,我建议您看一下VideoLAN项目的源代码:
http://en.wikipedia.org/wiki/VideoLAN [ http://www.videolan.org/ [ ^ ].

即使此产品主要用作播放器,它最初还是作为流解决方案开发的,无论有没有UI,它都可以用于许多不同的目的:流,媒体格式转换,即时媒体转换,播放,链接所有运行中的操作等等.原则上,您可以从源代码中学习所有技术.

VideoLAN提供了与.NET的某些互操作性.请查看是否可以为您提供帮助:
http://wiki.videolan.org/C_Sharp [
Quick answer is: bad idea. FTP cannot guarantee required frame rate. However, in practice, available media streaming solutions also do not guarantee uninterrupted supply of data required for smooth viewing, so you can try. Realistically, nothing prevents you from downloading of a whole media file from FTP to a temporary location and playing. To work with FTP, you need the class System.Net.FtpWebRequest:
http://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest.aspx[^].

Look at the code sample at the end of this page. Normally, you are reading the data from the Stream you obtain from System.Net.FtpWebResponse using System.Net.FtpWebResponse.GetResponseString and read data by chunks, which can suit your purpose. Please see:
http://msdn.microsoft.com/en-us/library/system.net.ftpwebresponse.aspx[^],
http://msdn.microsoft.com/en-us/library/system.net.ftpwebresponse.getresponsestream.aspx[^].

Even though you can read data on the fly, streaming the data the way you can feed it to a player component is another big problem (again, think about downloading of the whole file to a temporary location and feeding the file location to the player). If you really want to solve the problem in a streaming-on-the-fly way, I would advice to look at the source code of VideoLAN project:
http://en.wikipedia.org/wiki/VideoLAN[^],
http://www.videolan.org/[^].

Even though this product is used mostly as a player, it was initially developed as a streaming solution and can be used for many different purposes, with UI or without it: streaming, media format conversion, media transformations on the fly, playing, chaining all of the operations on the fly and more. In principle, you can learn all of the techniques from the source code.

VideoLAN provides some interoperability with .NET. Please see if it can help you:
http://wiki.videolan.org/C_Sharp[^].

—SA


这篇关于如何从ftp播放视频? .网的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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