Streaming Music Web-server pt3

Streaming Music Web-server pt3

So now we have our server setup it is now time to create a sample page and test it.

First lets create a simple page call play.html and we will place that in our web server directory.

Use your favorite editor and add the following code:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Sample Music</title>
</head>

<body>

<audio controls>
  <source src="bensound-ukulele.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>

</body>
</html>

The code above is pretty self explanatory the only item of note is the bensound-ukulele.mp3 I downloaded this song from the following site: https://www.bensound.com/royalty-free-music/track/ukulele

This is a royalty free site so we are free to use the music in our example. So once you download that MP3 upload it and the above play.html and point to your web browser with your IP to address an view page.

Another way you can create and download the file is log into your raspberry pi and open a terminal window. you can type the following command:

cd var/www/html

This will take you to the correct web directory.

Then type the following command:

nano play.html

This will create a file in linux text editor, copy the above code into the editor and the press ctrl-x to save.

Next in order to get the file that we use in the demo type the following command:

wget https://www.bensound.com/bensound-music/bensound-ukulele.mp3

This command tells linux to download the file and save it to the current directory.

Once all these steps are done you can view the page in your browser.

So let me know what you think. Tell me if I lost your or if there should be any corrections. Happy Coding!!!

Leave a Reply

Your email address will not be published. Required fields are marked *