首页 新闻 会员 周边

HTML5弄的网页播放器播放本地文件却在Chrome中播放不了,有放入本地服务器

0
悬赏园豆:100 [待解决问题]
<html>
<body>

<audio autoplay="autoplay" src="/i/song.mp3" controls="controls" loop="loop">
  <source src="/i/song.ogg" type="audio/ogg" />
  <source src="/i/song.mp3" type="audio/mpeg" />
Your browser does not support the audio element.
</audio>
<input id="fileurl" type="file" onchange="play()"/>

<script  language= "javascript " >
function play(){
try{
    var file=document.getElementById('fileurl').files[0];
    var reader = new FileReader();
    reader.onload = (function(file) {
        return function(e){
            $("audio").attr('src',e.target.result);
            $("source").attr('src',e.target.result);
        }
    })(file);
    reader.readAsDataURL(file);

 }
catch(e){   alert("同学,该换浏览器啦!!还在忍受龟速浏览器么,用谷歌Chrome吧!"); }  
}
</script>
</body>
</html>
Claruarius的主页 Claruarius | 初学一级 | 园豆:102
提问于:2012-06-17 15:48
< >
分享
所有回答(1)
0

之所以不播放,是因为你的代码不兼容W3C标准 

创想中国(羲闻) | 园豆:209 (菜鸟二级) | 2012-06-19 08:45

请问,哪里不兼容。

支持(0) 反对(0) Claruarius | 园豆:102 (初学一级) | 2012-07-08 19:01
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册