Playing html5 audio in android browser

后端 未结 8 2255
一生所求
一生所求 2020-11-29 08:37

I have a javascript that plays audio in the browser, using the html5 tag. It works fine in the iPhone browser, but not in Android. (Testing using

相关标签:
8条回答
  • 2020-11-29 08:49

    I cannot figure this out either. BUT, this test page created by Apple plays HTML5 audio on the Android: http://www.apple.com/html5/showcase/audio

    how did apple do it?

    0 讨论(0)
  • 2020-11-29 08:54

    I got this working on a project using trigger.io deploying to a Nexus 7 running Android Jellybean, but the audio only plays if I use absolute URLs at the moment. I'm not sure what the relative path is yet to use audio from within my project, but hopefully this will help somebody out...

    (function() {
    
        var currentSound;
        // I have a div called "page"
        var soundcv = document.body;
    
        // This only works for one sound for simplicity's sake
        function playSound(sound){
    
            if (currentSound == null){
                var audio = document.createElement('audio');
                audio.src = sound;
                soundcv.appendChild(audio);
                currentSound = audio;
            }
    
            currentSound.play();
        }
    
        // This isn't a real audio file URL - replace it with one of your own
        playSound('http://example.com/example.mp3');
    })();
    
    0 讨论(0)
  • 2020-11-29 08:57

    Have you checked your audio format ?

    0 讨论(0)
  • 2020-11-29 09:03

    The latest Android browser in FroYo does not yet support the HTML5 audio element. This is not a bug, rather a feature that has yet to be implemented. It may come in Gingerbread.

    Update: The Gingerbread browser has the audio element.

    0 讨论(0)
  • 2020-11-29 09:05

    I've been tinkering all day on this and I finally got mine to work on my old Samsung Droid browser with the yahoo webplayer:

    <a href="somefolder/file.mp3"></a>
    <script type="text/javascript" src="http://webplayer.yahooapis.com/player.js"></script>
    

    Works great puts a little arrow icon next to the text that you can click to play your mp3. Thanks Yahoo.

    I forgot to mention that the audio does NOT show up in my Chrome or Firefox browser when testing this locally. Works great on my phone browser though.

    0 讨论(0)
  • 2020-11-29 09:06

    Here is link to Google Android bug, which filed for lack of support of AUDIO tag in Android. Please, vote on it.

    http://code.google.com/p/android/issues/detail?id=10546

    BTW, there is work around, which let you play natively MP3 in Android 1.6 .. 2.2, like that:

    <video src="test.mp3" onclick="this.play();"></video>
    
    0 讨论(0)
提交回复
热议问题