I am trying to add a progress bar to show what position a song is at during playback. It only needs to be a simple solution. I found some code online, which uses SoundManager2 http://www.schillmania.com/projects/soundmanager2/ features to adjust a div width to match the song's position but it doesn't seem to be working, not sure where I am going wrong, any help would be appreciated.
I have used all the required Soundmanager2 files and playback of the songs work. It's only the progress bar which is the issue.
here is the javascript:
soundManager.setup({
url: '/swf',
preferFlash: false,
waitForWindowLoad: true,
onready: function() {
var myTrack1 = soundManager.createSound({
id: 'trackOne', url: 'msamples/beep-1.mp3', volume: 80, autoPlay: false,});
$(".progBar").css('width', ((this.position/this.duration) * 100) + '%');
$("li.a5 a").click(function(event){soundManager.play('trackOne');});
},
ontimeout: function() {
// Uh-oh. SWF missing, Flash blocked or other issue
}
});
The HTML links use this format and the progress bar sits below:
<li class="a5">Song1:
<a href="msamples/beep-1.mp3" title="Play" class="sm2_button">Play</a>
<div id="track1"><div class="progBar"></div></div>
</li>
The CSS is:
#track1 {
background-color: #333333;
height: 10px;
margin-top: 10px;
position: relative;
width: 100%;
}
.progBar {
background-color:#FFF;
height:10px;
}
The idea is #track1 acts as the container for the progress bar and .progBar is the div which has it's width adjusted through the $(".progBar").css('width', ((this.position/this.duration) * 100) + '%');
code.
Thanks in advance for your help.