I am using jQuery 1.5 and jPlayer 2.0.0, please ignore the fact that it will automatically play music, I am going to provide a sufficient warning before it starts, the user needs to press a large button to start the page and I will provide a large STOP button .
I would like the audio file to start playing, and the function is called after the page is ready and the sound is loaded.
I have the following javascript (I changed the code so that it can be better understood).
function FemeMusic() {
FemeMusic.prototype.addMusic = function(actionAfterMusic) {
$("#jp").jPlayer({
ready: function() {
var jPlayerElement = $(this);
jPlayerElement.jPlayer('setMedia', {
mp3: 'aSongByJamesBlunt.mp3'
});
jPlayerElement.bind($.jPlayer.event.progress,
function(event) {
if (event.jPlayer.status.seekPercent === 100) {
jPlayerElement.jPlayer("play");
}
if (actionAfterMusic) {
actionAfterMusic.call();
}
});
},
swfPath: "/flash",
preload: "auto"
});
}
}
I have this function to run the above code.
$(document).ready(function() {
var femeMusic = new FemeMusic();
femeMusic.addMusic(killMyself);
});
, $.jPlayer.event.loadeddata if $.jPlayer.event.progress, , , flash, ( firefox 3.5, ). , , Firefox
" , :
event.jPlayer.status.seekPercent === 100. "
http://groups.google.com/group/jplayer/browse_thread/thread/9dc9736f9d6947bd?pli=1
- ?
Edit
chrome safari, 3.6 Firefox ( ), , , , event.progress id :
jPlayer, Flash HTML5
event.progress, . , .
.