Dead Simple Audio for the Web
quizlet.github.io/mp3.js
<html>
<head>
...
<script type="text/javascript" src="/path/to/mp3.js" />
</head>
...
var player = new AudioPlayer();
// easy playing
player.play('/hammertime.mp3');
// supports preloading
player.preload('/what-the-fox-say.mp3');
// plays audio with custom callback events
// waits 5 seconds for the file to load before triggering onError
player.play('/all-along-the-watchtower.mp3', {
onLoad: function() { console.log('Audio Loaded!'); },
onError: function() { console.log('Error Loading Audio!'); },
onStop: function() { console.log('Audio Stopped Playing!'); },
timeout: 5000
});
// stop everything at any time
player.stopAll();
// or just stop playing a single file
player.stop('/hammertime.mp3');