0

我的音频播放器 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");
    } 

我为代码块道歉,但我不想遗漏任何东西。

4

1 回答 1

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");
    }
   });
于 2013-03-27T17:05:51.140 回答