I am trying to pass in a variable for "time" in jPlayer's play function, but it never seems to work.
The method looks like this:
$(id).jPlayer( "play", [Number: time] )
The example given in the documentation is like this:
$("#jpId").jPlayer("play", 42); // Begins playing 42 seconds into the media.
In my implementation, it looks like this:
var seconds = '300';
var mp3 = 'my_mp3_path';
console.log("seconds is: "+seconds);
$("#jquery_jplayer_1").jPlayer({
ready: function(event) {
$(this).jPlayer("setMedia", {
mp3: mp3
});
$(this).jPlayer("play", seconds);
},
errorAlerts: true,
swfPath: "/js",
supplied: "mp3, oga",
solution:"html,flash"
});
The console shows "seconds is 300".
The mp3 variable works.
But for some reason, the time variable ("seconds") does not work at all! No matter what I enter, it always starts from zero (and does play the correct mp3). The "time" seems to be undefined, but I don't know how to define it. In all the documentation, the time variable is specified with a number, not a variable, so I'm not sure what I can change to make it work.. Is this possible?
The argument to jPlayer
should be a number, not a stringified number:
var seconds = 300;