先上程式碼
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="format-detection" content="telephone=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<title>test</title>
<script src="static/lib/jquery/jquery-1.10.1.min.js"></script>
</head>
<body>
<p class="loading"></p>
<script>
$(document).ready(function (){
/*------------ 初始化 -------------*/
//加载音乐
var LoadAudio = function (src){
this.audio = document.createElement('audio');
this.audio.src = src;
};
LoadAudio.prototype = {
constructor : LoadAudio,
play : function (){
this.audio.play();
},
pause : function (){
this.audio.pause();
},
isLoadFn : function (callback){
var that = this;
this.audio.addEventListener('canplaythrough', function (){
callback(true);
}, false);
}
};
var callMusic = new LoadAudio('static/images/call.mp3');
callMusic.isLoadFn(function (result){
alert(result);
if(result){
$('.loading').fadeOut();
}
});
});
</script>
</body>
</html>
現在的問題是行動端在用流量的時候不能正常加載,
用WIFi可以,不知道什麼問題,難道canplaythrough監聽事件不是時時監聽的?
該如何修改,請大神指點。