I have a problem. Progress bar fills up faster than the video ends with a file. The progress bar is full, and the video is not finished yet.
$('.media_audio_player').bind('timeupdate' ,function() {
var id = $(this);
var idn = 'AudioBar_wrap\+'+this.id.split('rolf')[1];
var canvas = document.getElementById(idn);
if (canvas.getContext) {
var ctx = canvas.getContext("2d");
var lingrad = ctx.createLinearGradient(0,0,0,150);
var fWidth = (id.get(0).currentTime / id.get(0).duration) * (canvas.clientWidth);
if (fWidth > 0) {
lingrad.addColorStop(0, '#ebbdbd');
lingrad.addColorStop(0.5, '#dd6060');
lingrad.addColorStop(1, '#dc4c4c');
ctx.fillStyle = lingrad;
ctx.fillRect(0, 0, fWidth, 150);
}
}
});
Any help would be greatly appreciated.
also you can make next:
where CanvasWidth= length canvas, which is populated before the file finishes playing.
in your case: