我在网站上将jplayer用作音频播放器...大多数命令是 HTML5标准

我正在尝试触发 $ .jPlayer.event.progress 事件,以便我可以记录其值,如果> 0,我知道音频流正在用户计算机上播放。

问题是我无法从中得到结果,而我的jquery是...好...还不那么高级:)

由于我缺乏测试知识,所以我真的不能摆弄小提琴,我只能说流可以正常工作。

我希望看到的结果在“0到10”之间(0表示不流式传输)(1-10表示在几秒钟内缓冲的数据量)

HTML:

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.jplayer.min.js"></script>
<script type="text/javascript" src="/testsite/scripts/player.js"></script>



</head>

<body>

<p id="message"></p>

<br>


<div id="liveStream"></div>
<button onclick="playPause()">PLAY or PAUSE</button>
<button onclick="changeVolume('+')">Volume Up</button>
<button onclick="changeVolume('-')">Volume Down</button>
<button onclick="playStatus()">Play Status</button>


</body>
</html>
</body>

</html>

脚本:

我正在尝试从中返回 playstatus 函数,由于我缺乏理解,您可能会看到即时消息试图将所有内容记录在函数中
function playStatus(){
     $("#liveStream").bind($.jPlayer.event.progress, function (event) {
        console.log(event);
        console.log(playStatus);
        console.log(liveStream);
    });
}

//Initiate JPLAYER

$(document).ready(function(){

    var stream = {
        mp3: "http://streaming.radionomy.com/ABC-Jazz"

    },
    ready = false;

    $("#liveStream").jPlayer({
        ready: function (event) {
            ready = true;
            $(this).jPlayer("setMedia", stream);
        },
        pause: function() {
            $(this).jPlayer("clearMedia");
        },
        error: function(event) {
            if(ready && event.jPlayer.error.type === $.jPlayer.error.URL_NOT_SET) {
                // Setup the media stream again and play it.
                $(this).jPlayer("setMedia", stream).jPlayer("play");
            }
        },
        swfPath: "js",
        supplied: "mp3",
        preload: "none",
        wmode: "window",
        keyEnabled: true
    });


});

这是指向JPlayers DEV列表的链接,我正在尝试启动和登录 $ .jPlayer.event.progress

JPLAYER EVENTS

感谢您抽出宝贵的时间阅读!

最佳答案

如果您需要做的只是检查播放器是否在播放,则可以使用像这样的基本技巧来查看播放按钮是否隐藏(如果隐藏了,则表示正在播放,因为暂停按钮可见) )。

if( $('.jp-play').is(':hidden') ) {
    // it's playing
} else {
    // it's not playing
}

10-04 22:55