Below is a sample of the mp3 player. When the play button is clicked the player will start to download and play an mp3.
[MP3] Sample mp3 (25.29 MiB)
For accessibility reasons, a direct link to the mp3 files should also be provided alongside the Flash-embedded mp3. This is to allow the listeners a convenient way to download the mp3 file and listen to it using a playback device of their choice.
In order to add an mp3 player to a page the code below needs to be inserted with a few changes. The portions that are in bold need to be changed to point to the proper locations of the files.
mp3-player.swf fileAny code that is not in bold should not be edited in the following code.
<?php
function insert_mp3_player($title, $mp3, $swf) {
$flinkString = $title . '[' . $mp3 . ']';
echo <<<END
<object type="application/x-shockwave-flash" data="$swf" width="251" height="21">
<param name="movie" value="$swf"/>
<param name="FlashVars" value="mp3URL=$mp3"/>
</object>
END;
echo "<p>";
filelink($flinkString);
echo "</p>";
}
insert_mp3_player('mp3 title', '/path/to/your.mp3','/path/to/mp3-player.swf');
?>
[ZIP] Flash mp3 player (9 KiB)