Skip to content

Instantly share code, notes, and snippets.

@jordandobson
Created February 18, 2010 01:09
Show Gist options
  • Save jordandobson/307215 to your computer and use it in GitHub Desktop.
Save jordandobson/307215 to your computer and use it in GitHub Desktop.
var trkTimeTotal = 50000; // 50 seconds in milliseconds
var trkTimeStart = 10000; // 10 seconds in milliseconds
$(document).ready(function(){
$("#jquery_jplayer").jPlayer({
ready: function () {
$(this).setFile("mp3/10SecondsIn.mp3").play();
},
volume: 100,
oggSupport: false
})
.jPlayerId("play", "player_play")
.jPlayerId("pause", "player_pause")
.onProgressChange( function(loadPercent, playedPercentRelative, playedPercentAbsolute, playedTime, totalTime) {
$('#player_progress_play_bar').width((((trkTimeStart+playedTime)/trkTimeTotal)*100)+"%");
$('#player_progress_not_loaded').width(((trkTimeStart/trkTimeTotal)*100)+"%");
var myPlayedTime = new Date(playedTime+trkTimeStart);
var ptMin = (myPlayedTime.getUTCMinutes() < 10) ? "0" + myPlayedTime.getUTCMinutes() : myPlayedTime.getUTCMinutes();
var ptSec = (myPlayedTime.getUTCSeconds() < 10) ? "0" + myPlayedTime.getUTCSeconds() : myPlayedTime.getUTCSeconds();
$("#play_time").text(ptMin+":"+ptSec);
})
.onSoundComplete( function() {
$(this).stop();
// Reset these
$('#player_progress_play_bar').width("0%");
$('#player_progress_not_loaded').width("0%");
$("#play_time").text("00:00");
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment