我正在尝试使用 HTML5 和 Javascript 在 Chrome 中制作音频播放器。但是我一开始就遇到了一个错误(文件不可读)......
下面是我的 HTML 代码:
<head>
<meta charset="utf-8" />
<!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
Remove this if you use the .htaccess -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>index</title>
<meta name="description" content="" />
<meta name="generator" content="Studio 3 http://aptana.com/" />
<meta name="author" content="liuuzyan" />
<!--<meta name="viewport" content="width=device-width; initial-scale=1.0" />-->
<!-- Replace favicon.ico & apple-touch-icon.png in the root of your domain and delete these references -->
<link rel="shortcut icon" href="/favicon.ico" />
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
<script src="js/jquery-1.6.1.min.js" type="text/javascript"></script>
<script src="js/fun.js" type="text/javascript"></script>
</head>
<body>
<audio id="player" controls="controls">
Please use Firefox/Chrome/IE9 to browse this page.
</audio>
<input type="file" multiple="multiple" id="fileChose" />
</body>
下面是我的 Javascript 代码:
$(document).ready( function() {
$('#fileChose').change( function() {
var fileList=this.files;
for(var i=0;i<fileList.length;i++) {
var reader=new FileReader();
reader.onloaded=function(e){
$('#player').attr('src',e.target.result)
}
reader.onerror=function(e){
switch(e.target.error.code) {
case e.target.error.NOT_FOUND_ERR:
alert("file not found");
break;
case e.target.error.NOT_READABLE_ERR:
alert("file not readable");
break;
case e.target.error.ABORT_ERR:
alert("aborted");
break;
default:
alert('generic error?');
}
}
reader.readAsDataURL(fileList[i]);
}
});
});
谁能帮我解决这个问题?非常感谢!