一段音乐播放代码,我想让它自动播放,不知道改哪儿,请高手帮忙看下,代码如下 10
varplaybox=(function(){//author:eric_wuvar_playbox=function(){varthat=this;that.box=n...
var playbox = (function(){
//author:eric_wu
var _playbox = function(){
var that = this;
that.box = null;
that.player = null;
that.src = null;
that.on = true;
//
that.autoPlayFix = {
on: false,
evtName: ("ontouchstart" in window)?"touchend":"click"
}
}
_playbox.prototype = {
init: function(box_ele){
this.box = "string" === typeof(box_ele)?document.getElementById(box_ele):box_ele;
this.player = this.box.querySelectorAll("audio")[0];
this.src = this.player.src;
this.init = function(){return this;}
this.autoPlayEvt(false);
return this;
},
play: function(){
if(this.autoPlayFix.on){
this.autoPlayFix.on = true;
this.autoPlayEvt(false);
}
this.on = !this.on;
if(true == this.on){
this.player.src = this.src;
this.player.play();
}else{
this.player.pause();
this.player.src = null;
}
if("function" == typeof(this.play_fn)){
this.play_fn.call(this);
}
},
handleEvent: function(evt){
this.play();
},
autoPlayEvt: function(important){
if(important || this.autoPlayFix.on){
document.body.addEventListener(this.autoPlayFix.evtName, this, false);
}else{
document.body.removeEventListener(this.autoPlayFix.evtName, this, false);
}
}
}
//
return new _playbox();
})();
playbox.play_fn = function(){
this.box.className = this.on?"btn_music on":"btn_music";
} 展开
//author:eric_wu
var _playbox = function(){
var that = this;
that.box = null;
that.player = null;
that.src = null;
that.on = true;
//
that.autoPlayFix = {
on: false,
evtName: ("ontouchstart" in window)?"touchend":"click"
}
}
_playbox.prototype = {
init: function(box_ele){
this.box = "string" === typeof(box_ele)?document.getElementById(box_ele):box_ele;
this.player = this.box.querySelectorAll("audio")[0];
this.src = this.player.src;
this.init = function(){return this;}
this.autoPlayEvt(false);
return this;
},
play: function(){
if(this.autoPlayFix.on){
this.autoPlayFix.on = true;
this.autoPlayEvt(false);
}
this.on = !this.on;
if(true == this.on){
this.player.src = this.src;
this.player.play();
}else{
this.player.pause();
this.player.src = null;
}
if("function" == typeof(this.play_fn)){
this.play_fn.call(this);
}
},
handleEvent: function(evt){
this.play();
},
autoPlayEvt: function(important){
if(important || this.autoPlayFix.on){
document.body.addEventListener(this.autoPlayFix.evtName, this, false);
}else{
document.body.removeEventListener(this.autoPlayFix.evtName, this, false);
}
}
}
//
return new _playbox();
})();
playbox.play_fn = function(){
this.box.className = this.on?"btn_music on":"btn_music";
} 展开
1个回答
展开全部
this.autoPlayEvt(false);该是true。。。。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
上海风华峻极智能科技
2022-05-05 广告
2022-05-05 广告
上海风华峻极智能科技有限公司【远程会议视频系统】一体化解决方案,如同面对面开会一般,让远程会议更简单,多种会议场景布局,舞台设备厂家,高保真语音的传输,极速快捷远程会议体验,只为高效沟通,支持万人及多房间同时在线....
点击进入详情页
本回答由上海风华峻极智能科技提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询