mare123
mare123

Reputation: 11

HTML5 Audio not playing on Chrome for Android

I have this simple demo website made up. It has an input button, and when you click on it, the audio file should play. The HTML-code is like this:

<audio id="ducksong">
    <source src="audio/ducks.mp3" type="audio/mpeg">
    <source src="audio/ducks.ogg" type="audio/ogg">
</audio>
<input id="playme" type="submit" value="Play me">

This is the corresponding JavaScript code:

var input = document.querySelector("input#playme");
var audio = document.querySelector("audio#ducksong");
input.addEventListener("click", function() {
    audio.play();
});

It works perfectly fine on desktop browsers and on Firefox for Android. But there's no sound on Chrome for Android. (I'm using Android 5.1)

I know that similar questions have been asked before, but that didn't help me. I know that Chrome for Android is special, in that it expects a user interaction before playing HTML5 audio, but I did implement this. Any help is very much appreciated.

Upvotes: 0

Views: 5425

Answers (1)

mare123
mare123

Reputation: 11

OK, I solved it myself. The .htaccess password protection, that I created, prevented the audio from playing on Chrome for Android. Although I logged into the web page and the site displayed correctly, audio could not be loaded. Safari on iOS had the same problem. Interestingly though, Firefox on Android worked just fine.

Upvotes: 1

Related Questions