开发者

jPlayer play next file

开发者 https://www.devze.com 2023-03-25 19:42 出处:网络
I\'m trying to use jPlayer for playing background music on service. Here is my code: if (command.indexOf(\'playmusic\') != -1) {

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();
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号