如何制作圈子jPlayer自动播放?

时间:2011-10-18 14:31:22

标签: jquery jplayer

有谁能告诉我如何制作这个自动播放器?

$(document).ready(function(){
    var myCirclePlayer = new CirclePlayer("#jquery_jplayer_1",
    {
        m4a:"x.mp3",
        oga: "x.ogg"
    }, {
        cssSelectorAncestor: "#cp_container_1"
    });
});

3 个答案:

答案 0 :(得分:19)

创建播放器后尝试此操作(documentation here):

$('#jquery_jplayer_1').jPlayer("play");

或者像这样实例化播放器:

  $(document).ready(function () {
      $("#jquery_jplayer_1").jPlayer({
         ready: function () {
             $(this).jPlayer("setMedia", {
                m4a:"x.mp3",
                oga: "x.ogg"
              }).jPlayer("play");
          },
          swfPath: "/scripts/Jplayer.swf",
          supplied: "m4a, oga"
      });
  });

答案 1 :(得分:14)

也许不是最好的解决方案,但它有效:

[...]
canplay: function() {
    $("#jquery_jplayer_1").jPlayer("play");
}

$(document).ready(function() {                           
    var myCirclePlayer = new CirclePlayer("#jquery_jplayer_1",
    {
        m4a: "http://www.jplayer.org/audio/m4a/Miaow-07-Bubble.m4a",
        oga: "http://www.jplayer.org/audio/ogg/Miaow-07-Bubble.ogg"
    }, {
        cssSelectorAncestor: "#cp_container_1",
        canplay: function() {
            $("#jquery_jplayer_1").jPlayer("play");
        }
    });
});

答案 2 :(得分:2)

希望我的博客可以帮助您解决问题http://gmarkmananquil.blogspot.com/2012/01/jplayers-circleplayer-ie-issue.html并下载脚本。以上都不适合我,所以只是尝试一下我的工作。

以下是我在此插件中实现自动播放的解决方法,首先将自动播放属性添加到第35行中的circleplayer脚本中的默认对象变量。

defaults = {
            // solution: "flash, html", // For testing Flash with CSS3
            supplied: "mp3",
            solution: "flash,html",
            // Android 2.3 corrupts media element if preload:"none" is used.
            // preload: "none", // No point preloading metadata since no times are displayed. It helps keep the buffer state correct too.
            cssSelectorAncestor: "#cp_container_1",
            cssSelector: {
                play: ".cp-play",
                pause: ".cp-pause"
            },
            autoplay: false // add this autoplay default to false
        },

其次,使用此代码

修改第98行中的脚本
if(self.options.autoplay){
     $(this).jPlayer("setMedia", self.media).jPlayer('play');
   }
else{
    $(this).jPlayer("setMedia", self.media);
   }

脚本的示例用法就是这样,

var myCirclePlayer = new CirclePlayer("#jquery_jplayer_1",{
        mp3: "music/booty me down.mp3"
    }, {
        cssSelectorAncestor: "#cp_container_1",
        swfPath: "js",
        wmode: "window", size : { width:"40px" },
                autoplay: true
    }
    );