How to Create an MP3 Player in PHP

By Fred Larrey

Create an MP3 Player For Your Website
i mp3 player image by patrimonio designs from

MP3 audio files can be easily embedded into your website using some simple PHP and HTML scripting. One way to create an MP3 player on your website would be to embed the MP3 file directly, however this can lead to problems on the client-side, because not everyone uses the same media browser plug-ins. To get around this problem, Google provides a freely available embed-able MP3 player. It automatically loads time information about the song you are playing and has a volume slider and time progress bar that allows you to skip within the song. Best of all, it works and looks the same on all computers.

Step 1

Open up your favorite text editor. Any text editor will do. This is where you will write your PHP script.

Step 2

Type the following PHP script into your text editor:

\" GO Echo \"PHP Mp3 Player\" GO Print \"My MP3 Player:\" GO Echo \"\" GO ?>

Step 3

Select the \"MP3_FILE_URL\" text within the last Echo statement. Change it to the URL of your MP3 file on your server. For example, if your server was named \",\" the URL might look like: \"\".

Step 4

Go to \"File\" > \"Save As\" and type \"mp3player.php\" as the name of the file. Navigate to the root directory of your web server and click \"Save.\"

Step 5

Open a web browser and type \"http://localhost/mp3player.php\" to open your MP3 player website. You will see the Google MP3 player, and you'll hear your MP3 file start to play. Remember, your web server will need to be running in order to use PHP. See the Tips section for more information on how to create a web server.