How to Create an MP3 Player in PHPby Fred Larrey
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.
Open up your favorite text editor. Any text editor will do. This is where you will write your PHP script.
Type the following PHP script into your text editor: \" GO Echo \"
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 \"myserver.com,\" the URL might look like: \"http://myserver.com/mysong1.mp3\".
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.\"
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.
- PHP is a web-based programming language, so in order to test or run PHP script you'll need access to a web server. If you are not running one, you can find some helpful information in the Resources section that will lead you in the right direction.
Items you will need
- Text Editor
- Web Server
- mp3 player image by patrimonio designs from Fotolia.com