Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Audio mp3 stream from static server NGINX

I have my web application which has many audio files. I have kept these files on my Nginx server.

On my HTML page, I am using audio tag. My question is when my HTML page loads on the web browser then do all the audio files will get downloaded at the same time? Or when the user plays particular audio file, then only that audio get streamed and downloaded.

Since my page has many audio files, so I need only that audio gets streamed/downloaded to the user which he plays.

like image 826
sorabh solanki Avatar asked Oct 21 '25 22:10

sorabh solanki


1 Answers

A given media file will only get downloaded after you have clicked on a link

You can confirm this yourself by getting onto your page in question then hit F12 or ctrl-shift-i in your browser (firefox/chrome/opera) to open up your developer tools then hit the Network tab which will display network traffic ... once there do a page refresh and observe traffic ... next to none since no media files have been requested

Now click on a media link to request a download and only then will you see significant network traffic as the media packets come tumbling into the browser

By default above setup will just download the mp3 not stream ... to stream an mp3 file create on server side a text file called mysong.m3u which contains URL of actual mp3 file

http:///sorabhdomain.com/mymedia/mysong.mp3

then have the browser link use the m3u URL not the mp3 URL and the browser should now stream not download

like image 155
Scott Stensland Avatar answered Oct 25 '25 02:10

Scott Stensland



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!