先上代码
<!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监听事件不是时时监听的?
该如何修改,请大神指点。
视频方面我用的Video.js 以前也用原生的,但是不怎么好用。兼容什么的都写好了