Vianne
Vianne

Reputation: 578

How to check if JPlayer is playing

How I can use Jquery to check if JPlayer is playing? I tried searching but it seems like all previous answers are already outdated as it doesn't work anymore with the latest version.

If(Jplayer is playing) {
    $("#id").css("display", "block");
} 
else {
    $("#id").css("display", "none");
}

Upvotes: 0

Views: 725

Answers (1)

Punit Gajjar
Punit Gajjar

Reputation: 4987

Try

$('.jp-play').click(function() {
  if($("#jquery_jplayer_1").data().jPlayer.status.paused === false){
                        $("p").show();
                    }
                    else{
                        $("p").hide();
                    }
});
$(document).ready(function(){
                $("#jquery_jplayer_1").jPlayer({
                    ready: function () {
                        $(this).jPlayer("setMedia", {
                            title: "Bubble",
                            m4a: "http://jplayer.org/audio/mp3/Miaow-07-Bubble.mp3",
                            oga: "http://jplayer.org/audio/ogg/Miaow-07-Bubble.ogg"
                        }).jPlayer("play");
                    },
                    swfPath: "http://jplayer.org/latest/dist/jplayer",
                    supplied: "mp3, oga",
                    wmode: "window",
                    useStateClassSkin: true,
                    autoBlur: false,
                    smoothPlayBar: true,
                    keyEnabled: true,
                    remainingDuration: true,
                    toggleDuration: true
                });

                setTimeout(function(){
                    if($("#jquery_jplayer_1").data().jPlayer.status.paused === false){
                        $("p").hide();
                    }
                    else{
                        $("p").show();
                    }
                }, 500);
            }); 

Upvotes: 3

Related Questions