使用JavaScript的Html5音频将无法使用除chrome之外的任何浏览器 [英] Html5 Audio with JavaScript won't work any browser other than chrome

查看:83
本文介绍了使用JavaScript的Html5音频将无法使用除chrome之外的任何浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用JavaScript的Html5音频将无法使用除chrome以外的任何浏览器

基本上按下按钮我希望能够将当前曲目切换到另一个。这最终在Chrome中有效,但在其他任何浏览器中都没有?


< !DOCTYPE html PUBLIC - // W3C // DTD XHTML 1.0 Transitional // EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd >
< html xmlns = http:// www.w3.org/1999/xhtml\">

< head >
< ; meta content < span class =code-keyword> = text / html; charset = utf-8 http-equiv = 内容类型 / >
< 标题 > MediaPlayer无法在Chrome以外的任何浏览器中使用< / title >
< script type = text / javascript >
function test (){
var Mp3Me = document.getElementById('Mp3Me');
Mp3Me.src =http://media.rolandus.com/mp3/v-piano_vintage_piano_1.mp3;
}

< / script >

< / head >

< 正文 >
< 音频 id = Mp3Me autoplay autobuffer 控制 >
< source src = Batman.mp3 type = audio / mpeg >
< / audio >

< < span class =code-leadattribute> a
href = javascript:测试() > 启动钢琴曲目< / a >

< / body >

< / html >

解决方案

audio 是一个HTML5标记,并不支持它。请阅读有关使用和支持的文章: http://html5doctor.com/html5-audio-the-状态/ [ ^ ]

Html5 Audio with JavaScript won't work any browser other than chrome

Basically on button press I want to be able to switch the current track to another. This works finally in Chrome but not in any other browser?


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">

    <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    <title>MediaPlayer Won't Work in Any browser other than chrome</title>
    <script type="text/javascript">
    function Test(){
    var Mp3Me= document.getElementById('Mp3Me');
    Mp3Me.src = "http://media.rolandus.com/mp3/v-piano_vintage_piano_1.mp3";
    }

    </script>

    </head>

    <body>
        <audio id="Mp3Me" autoplay autobuffer controls>
      <source src="Batman.mp3"  type="audio/mpeg">
    </audio>

    <a href="javascript:Test()">Start Piano Track</a>

    </body>

    </html>

解决方案

audio is a HTML5 tag, and it is not supported all around. Please read this article about usage and support: http://html5doctor.com/html5-audio-the-state-of-play/[^]


这篇关于使用JavaScript的Html5音频将无法使用除chrome之外的任何浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆