/
-/public
--/js
--- audio5.js
--/swf
--- audio5js.swf
<script src="/js/audio5.js"></script>
<script>
function initAudio () {
var audio5js = new Audio5js({
ready: function () {
this.load('/someaudio.mp3');
this.play();
}
});
}
initAudio();
</script>
var audio5js = new Audio5js({
swf_path: './swf/audio5js.swf',
codecs: ['mp4', 'vorbis', 'mp3'],
ready: function(player) {
var audio_url;
switch (player.codec) {
case 'mp4':
audio_url = '/audio/song.mp4';
break;
case 'vorbis':
audio_url = '/audio/song.ogg';
break;
default:
audio_url = '/audio/song.mp3';
break;
}
this.load(audio_url);
this.play();
}
});
<a id="play">Play / Pause</a>
<a id="seek">Move to Start</a>
Playback API
Audio5js lets you control the life-cycle of audio playback with the following API:
- load - Load an audio file to the player
- play - Play loaded audio
- pause - Pause playing audio
- playPause - Toggle audio play / pause
- volume - Get / Set audio volume
- seek - Seek audio to time
You should note the following when using the playback API:
- Volume values range from 0 to 1.
- Seek values are should be passed asseconds of total audio duration.