jPlayer play next file
I'm trying to use jPlayer for playing background music on service.
Here is my code:
if (command.indexOf('playmusic') != -1) {
var player = document.getElementById('jpId');
$(player).jPlayer(
{
ready: function () {
$(this).jPlayer("setMedia", {
mp3: "../../audio/1.mp3"
开发者_如何学JAVA }).jPlayer("play");
}, supplied: "mp3"
}
);
}
if (command.indexOf('playnext') != -1) {
var player = document.getElementById('jpId');
$(player).setFile("../../audio/2.mp3");
$(player).play();
}
but playnext part of code not working:
Uncaught TypeError: Object [object Object] has no method 'setFile'
What I'm doing wrong?
Thanx!
I think you should do
$('#jpId').jPlayer('setMedia', {
mp3: '../../audio/2.mp3',
}).jPlayer('play');
Instead of
var player = document.getElementById('jpId');
$(player).setFile("../../audio/2.mp3");
$(player).play();
精彩评论