1
votes

Hello guys i hope you can help me with this problem...

I use Phonegap 3.1 and jQuery Mobile 1.4 ... Android 4.1.2

When I test the app in Firefox the audio player works perfect but when tested on the phone the player is visible but when I click on play nothing happens ...

Tried mp3 and ogg so it should support all browsers...

I saw lot lot of threads on StackOverflow ... even tried MediaElement.js as suggested ... but nothing seems to work ...
I know about the native media API ... but I really don't want to use it ... So I wonder if anyone has found a solution with this annoying problem ?

Thanks

1
if I use a .ogg file from a server it plays the sound ... but it only plays once and then is imposible to replay ...LitBe
i'm currently searching for the same answer to this question. found out that chrome blocks autoplay on android and your app is essentially in-browser. don't know if this mattersDaniel Cheung

1 Answers

0
votes

Html

<audio id="play_audio" autoplay="autoplay" controls preload>
    <source src="your_audio_url" type="audio/mpeg" codecs="mp3"></source>
    <source src="your_audio_url" type="audio/mp4" codecs="mp4a.40.5 "></source>
    <source src="your_audio_url" type="audio/ogg" codecs="vorbis"></source>
</audio>

Javascript

$(document).ready(function(){
    $("#play_audio").click(function(){
        $(this).load();
        $(this).play();
    })


})