C #: Stream audio file from server to client

I am currently writing an application that will allow the user to install some form of application (possibly a Windows service) that will open a port on it and provide a specific place on the hard drive, then it will be able to stream mp3 files.

Then I will have another application that will connect to the server (which is the user computer) and be able to view the hosted data by connecting to this computer (remotely, of course) based on the port, and mp3 stream files from the server to the application


I found several tutorials on the Internet, but most of them focus on file servers in C #, and they allow you to download the entire file. What I want is an mp3 file stream so that it starts playing when a certain number of bytes are downloaded (i.e. while it is buffered).


How do I solve this problem? What I need to know specifically is how to write this application (I will turn into a Windows Service later) that will listen to the specified port as streaming files so that I can then access the files using something like: http://<serverip>:65000/acdc/wholelottarosie.mp3 and hopefully can transfer this file to WPF MediaPlayer .


[Update]

I followed this tutorial about creating a file server and sending a file from the server to the client. Am I doing something like that?

[Update]

This post is currently being read: Play audio from a stream using C # , and I think it looks very promising as to how I can play streaming files; but I still don't know how I can actually transfer files from the server.

+6
c # wpf audio streaming
source share
2 answers

There is no effective difference between streaming and downloading. This is the same. Any difference is purely semantic.

If you wanted, you could โ€œdownloadโ€ MP3 from any web server and start playing it while it is downloading. It just requires that you copy some data and immediately send it to your decoding and playback procedures.

Similarly, even so-called "streaming" servers can be loaded. You just need to save the bytes, as they are transmitted over the channel to the file.

Streaming applications are simply applications that are not designed to save files to disk.

EDIT:

There is an exception. Two really:

Firstly, if you broadcast live audio, such as radio or other types where you do not need 100 percent reliability, then they transmit the stream via UDP. This can be saved if you want, but it is more package oriented than stream oriented.

Secondly, when encryption is used, in which case you can still save the file, but it will be useless without the encryption algorithm and keys.

+7
source share

This is simply not true.

The difference between downloading a file and an HTTP media stream is the encoding header that is configured to encode the stream. In addition, the file download has a Content-Length header, so the recipient system can know the file size in advance.

There is no Content-Length header with a multimedia stream, so there is no expected endpoint. Most likely, only a continuous series of pieces of data is received and processed as long as they continue to appear.

+2
source share

All Articles