我的Jplayer是一个音频播放器,我遇到了一些麻烦。我无法访问isPaused。我需要做的是当玩家正在玩时,div的背景图像需要改变。我有两个测试脚本,都没有正常工作。
我的播放器
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"
});
我的包装。
<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>
这应该有效,但出于某种原因不行。
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");
}
我也有这个代码可以正常工作,当玩家没有玩,没有显示暂停按钮,玩家正在玩时,它的风格变成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");
}
我为代码块道歉,但我不想遗漏任何东西。
答案 0 :(得分:1)
您可以通过以下操作挂钩jPlayer中的play
,pause
和end
事件:
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");
}
});