I am currently writing an application that will allow a user to install some form of an application (maybe a Windows Service) that will open a port on it's PC and given a particular destination on the hard disk, will then be able to stream mp3 files.
我目前正在编写一个应用程序,允许用户安装某种形式的应用程序(可能是Windows服务),该应用程序将在其PC上打开一个端口,并在硬盘上给出一个特定的目标,然后就可以流式传输mp3文件。
I will then have another application that will connect to the server (being the user's pc) and be able to browse the hosted data by connecting to that PC (remotely ofcourse) given the port, and stream mp3 files from the server to the application
然后,我将有另一个应用程序连接到服务器(作为用户的PC),并能够通过连接到该PC(远程)来给定端口数据浏览托管数据,并将mp3文件从服务器流式传输到应用程序
I have found some tutorials online but most of them are about File Servers in C# and they download allow you to download a whole file. What I want is to stream an mp3 file so that it starts playing when a certain number of bytes are download (ie, whilst it is being buffered)
我在网上找到了一些教程,但其中大部分是关于C#中的文件服务器,它们下载允许您下载整个文件。我想要的是流式播放一个mp3文件,以便在下载一定数量的字节时开始播放(即,当它被缓冲时)
How do I go about in accomplishing such a task? What I need to know specifically is how to write this application (that I will turn into a Windows Service later on) that will listen on a specified port a stream files, so that I can then access the files by something of the sort: http://<serverip>:65000/acdc/wholelottarosie.mp3
and hopefully be able to stream that file in a WPF MediaPlayer
.
我该如何完成这项任务?我需要具体知道的是如何编写这个应用程序(稍后我将转为Windows服务),它将在指定的端口上侦听流文件,以便我可以通过以下类型访问文件:http ://
[Update]
[更新]
I was following this tutorial about building a file server and sending the file from the server to the client. Is what I have to do something of the sort?
我正在学习如何构建文件服务器并将文件从服务器发送到客户端。我必须做些什么吗?
[Update]
[更新]
Currently reading this post: Play Audio from a Stream using C# and I think it looks very promising as to how I can play streamed files; but I still don't know how I can actually stream the files from the server.
目前正在阅读这篇文章:使用C#从一个流播放音频,我认为我看起来如何播放流媒体文件非常有前景;但我仍然不知道如何实际从服务器流式传输文件。
2 个解决方案
#1
7
There is no effective difference between streaming and downloading. They're the same thing. Any difference is purely semantic.
流媒体和下载之间没有有效的区别。他们是一回事。任何差异都纯粹是语义上的。
If you wanted to, you could "download" an MP3 from any web server and start playing it while you were downloading it. It just requires that you buffer some of the data and start sending it to your decoding and playback routines right away.
如果您愿意,可以从任何Web服务器“下载”MP3并在下载时开始播放。它只需要缓冲一些数据并立即将其发送到解码和回放例程。
Similarly, even so called "streaming" servers can be downloaded. You just have to save the bytes as they are being sent across the wire to a file.
类似地,甚至可以下载所谓的“流”服务器。您只需要保存通过线路发送到文件的字节。
"Streaming" applications are just apps that are not designed to save the files to disk.
“流式”应用程序只是不是为将文件保存到磁盘而设计的应用程序。
EDIT:
编辑:
There is an exception. Two really:
有一个例外。两个真的:
First, if you are streaming "live" audio, such as radio or other types where you don't need 100% reliability, then they stream using UDP. This can still be saved if you want, but it's more packet oriented than stream oriented.
首先,如果您正在流式传输“实时”音频,例如无线电或其他类型,您不需要100%的可靠性,那么它们会使用UDP进行流式传输。如果你愿意,这仍然可以保存,但它更多的是面向数据包而不是面向流。
The second is when encryption is used, in which case you can still probably save the file, but it would be useless without the encryption algorithm and keys.
第二种是使用加密时,在这种情况下你仍然可以保存文件,但如果没有加密算法和密钥,它将毫无用处。
#2
2
This is simply not true.
这是不正确的。
The difference between a file download and an HTTP multimedia stream is the encoding header, which is set to chunked encoding for a stream. In addition, a file download has a Content-Length header, so the recipient system can know the file size in advance.
文件下载和HTTP多媒体流之间的区别是编码头,其被设置为流的分块编码。此外,文件下载具有Content-Length标头,因此收件人系统可以提前知道文件大小。
There is no Content-Length header with a multimedia stream, therefore there is no expected end point. Rather, just a continual series of chunks of data are received and processed, for as long as they continue to appear.
没有带有多媒体流的Content-Length标头,因此没有预期的终点。相反,只要它们继续出现,就会接收和处理一系列连续的数据块。
#1
7
There is no effective difference between streaming and downloading. They're the same thing. Any difference is purely semantic.
流媒体和下载之间没有有效的区别。他们是一回事。任何差异都纯粹是语义上的。
If you wanted to, you could "download" an MP3 from any web server and start playing it while you were downloading it. It just requires that you buffer some of the data and start sending it to your decoding and playback routines right away.
如果您愿意,可以从任何Web服务器“下载”MP3并在下载时开始播放。它只需要缓冲一些数据并立即将其发送到解码和回放例程。
Similarly, even so called "streaming" servers can be downloaded. You just have to save the bytes as they are being sent across the wire to a file.
类似地,甚至可以下载所谓的“流”服务器。您只需要保存通过线路发送到文件的字节。
"Streaming" applications are just apps that are not designed to save the files to disk.
“流式”应用程序只是不是为将文件保存到磁盘而设计的应用程序。
EDIT:
编辑:
There is an exception. Two really:
有一个例外。两个真的:
First, if you are streaming "live" audio, such as radio or other types where you don't need 100% reliability, then they stream using UDP. This can still be saved if you want, but it's more packet oriented than stream oriented.
首先,如果您正在流式传输“实时”音频,例如无线电或其他类型,您不需要100%的可靠性,那么它们会使用UDP进行流式传输。如果你愿意,这仍然可以保存,但它更多的是面向数据包而不是面向流。
The second is when encryption is used, in which case you can still probably save the file, but it would be useless without the encryption algorithm and keys.
第二种是使用加密时,在这种情况下你仍然可以保存文件,但如果没有加密算法和密钥,它将毫无用处。
#2
2
This is simply not true.
这是不正确的。
The difference between a file download and an HTTP multimedia stream is the encoding header, which is set to chunked encoding for a stream. In addition, a file download has a Content-Length header, so the recipient system can know the file size in advance.
文件下载和HTTP多媒体流之间的区别是编码头,其被设置为流的分块编码。此外,文件下载具有Content-Length标头,因此收件人系统可以提前知道文件大小。
There is no Content-Length header with a multimedia stream, therefore there is no expected end point. Rather, just a continual series of chunks of data are received and processed, for as long as they continue to appear.
没有带有多媒体流的Content-Length标头,因此没有预期的终点。相反,只要它们继续出现,就会接收和处理一系列连续的数据块。