Click here to Skip to main content
15,887,988 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
XML
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>
Posted

1 solution

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/[^]
 
Share this answer
 
Comments
JackDaniels1932 8-Mar-13 8:00am    
Is there any workarounds you know of?? if it can't use the html5 player
Zoltán Zörgő 8-Mar-13 8:27am    
Non that is plugin-less. But there are several flash based ones for example, like these:
http://flash-mp3-player.net/
http://wpaudioplayer.com/standalone/

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900