谁能告诉我如何进行此自动播放?
$(document).ready(function(){
var myCirclePlayer = new CirclePlayer("#jquery_jplayer_1",
{
m4a:"x.mp3",
oga: "x.ogg"
}, {
cssSelectorAncestor: "#cp_container_1"
});
});
创建播放器后尝试此操作(此处的文档):
$('#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"
});
});
也许不是最好的解决方案,但它有效:
[...]
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");
}
});
});
希望我的博客可以帮助您解决问题http://gmarkmananquil.blogspot.com/2012/01/jplayers-circleplayer-ie-issue.html并下载脚本。以上都不适合我,所以请尝试一下我的工作。
这是我在这个插件中实现自动播放的解决方法,首先在第 35 行找到的 circleplayer 脚本中的 defaults 对象变量中添加自动播放属性。
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
}
);