I am having some trouble with my Jplayer which is an audio player. I am having trouble accessing isPaused. What I need to have happen is the background image of a div needs to change when the player is playing. I have two test scripts, neither are working proper.
My player
var myCirclePlayer = new CirclePlayer("#jquery_jplayer_1",
{
mp3: "/media/audio/RelaxSeg.mp3",
}, {
supplied: "mp3",
cssSelectorAncestor: "#cp_container_1",
swfPath: "/jQuery.jPlayer.2.2.0/v11/js",
wmode: "window"
});
My containter.
<div id="jquery_jplayer_1" class="cp-jplayer"></div>
<div id="cp_container_1" class="cp-container" style="background:none;">
<img id="bg_image" class="bg_image1" src="/jQuery.jPlayer.2.2.0/v11/circle.skin/jplayer_bg_img.png" height="60" />
<div class="cp-progress-holder"> <!-- .cp-gt50 only needed when progress is > than 50% -->
<div class="cp-progress-1"></div>
<div class="cp-progress-2"></div>
</div>
<div class="cp-circle-control"></div>
<ul class="cp-controls">
<li><a id="play1" class="cp-play" tabindex="1">play</a></li>
<li><a id="pause1" class="cp-pause" style="display:none;" tabindex="1">pause</a></li> <!-- Needs the inline style here, or jQuery.show() uses display:inline instead of display:block -->
</ul>
</div>
This should work, but for some reason doesnt.
if($("#jquery_jplayer_1").data("jPlayer").status.isPlaying) {
$(".bg_image1").attr("src", "/jQuery.jPlayer.2.2.0/v11/circle.skin/jplayer_bg_image_green.png");
}
else {
$(".bg_image1").attr("src", "/jQuery.jPlayer.2.2.0/v11/circle.skin/jplayer_bg_img.png");
}
I also have this code that doenst work either, when the player is not playing, the pause button is not displayed, and when the player is playing, its style becomes display=block.
if(document.getElementById("pause1").style.display = "block") {
$(".bg_image1").attr("src", "/jQuery.jPlayer.2.2.0/v11/circle.skin/jplayer_bg_image_green.png");
}
if(document.getElementById("pause1").style.display = "none") {
$(".bg_image1").attr("src", "/jQuery.jPlayer.2.2.0/v11/circle.skin/jplayer_bg_img.png");
}
I appologize for the block of code, but I didnt want to leave anything out.
You can hook into the play
, pause
and end
events in jPlayer by doing something like:
var myCirclePlayer = new CirclePlayer("#jquery_jplayer_1",
{
mp3: "/media/audio/RelaxSeg.mp3",
}, {
supplied: "mp3",
cssSelectorAncestor: "#cp_container_1",
swfPath: "/jQuery.jPlayer.2.2.0/v11/js",
wmode: "window",
play: function () {
$(".bg_image1").attr("src", "/jQuery.jPlayer.2.2.0/v11/circle.skin/jplayer_bg_img.png");
},
pause: function () {
$(".bg_image1").attr("src", "/jQuery.jPlayer.2.2.0/v11/circle.skin/jplayer_bg_image_green.png");
},
ended: function () {
$(".bg_image1").attr("src", "/jQuery.jPlayer.2.2.0/v11/circle.skin/jplayer_bg_image_green.png");
}
});