C#中:从流媒体服务器音频文件到客户端 [英] C#: Streaming an Audio file from a Server to a Client

查看:287
本文介绍了C#中:从流媒体服务器音频文件到客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在写一个应用程序,允许用户安装某种形式的应用程序(可能是Windows服务),将打开一个端口上的PC,并给予在硬盘上的特定目标,届时可到流MP3文件。

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.

我会再有,将连接到服务器(即用户的PC机)的另一个应用程序,并能够通过连接到PC(远程ofcourse)指定的端口,和流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


我已经发现了一些在线教程,但其中大部分是关于在C#中的文件服务器和他们下载,您可以下载整个文件。我想是这样,它启动时的字节一定数量的下载播放流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)


我如何去了解在完成这样的任务?我需要知道具体是怎么写的这个应用程序(我会变成一个Windows服务以后)将侦听一个指定端口的流文件上,这样我就可以通过诸如此类的东西访问文件:的http://< SERVERIP>:65000 / ACDC / wholelottarosie.mp3 ,希望能够流该文件在WPF 的MediaPlayer

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.


[更新]

我下面<一个href=\"http://www.dotnetspider.com/resources/4741-Building-Simple-File-download-server-using-C.aspx\">this关于建立一个文件服务器,并从服务器向客户机发送文件教程的。是我必须做的那种东西吗?

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?

[更新]

目前阅读这篇文章:使用从流播放音频C#我认为它看起来,我怎么能玩的流媒体文件非常有前途的;但我还是不知道我其实可以从服务器流式传输文件。

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.

推荐答案

有是流媒体和下载都没什么区别。他们是同样的事情。任何差异纯粹是语义的。

There is no effective difference between streaming and downloading. They're the same thing. Any difference is purely semantic.

如果你愿意,你可以下载从任何Web服务器的MP3,并开始播放它,而你是下载。它只是需要你缓存一些数据,并开始把它发送到您的解码和播放程序的时候了。

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.

类似地,即使所谓的流动的服务器可以下载。你只需要保存字节,因为他们正在通过线路发送到文件。

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.

编辑:

有一个例外。两个真:

首先,如果你是流活的音频,例如当你并不需要100%的可靠性无线电或其它类型的,那么他们流使用UDP。如果你想这仍然可以保存,但它是面向比面向流多数据包。

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.

二是加密时使用,在这种情况下,你仍然可以或许保存文件,但它是不加密算法和密钥无用的。

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.

这篇关于C#中:从流媒体服务器音频文件到客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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