codedread
codedread

Reputation: 1382

Cannot get HTML audio element to play on Chrome Android (no progress unless muted)

I'm posting this in case others have a similar problem.

I have a web app that uses the <audio> element. When the user clicks a button, I set the src attribute on the <audio> element to a URL of a mp3 file, then I call .load() and then .play(). The play() method's Promise resolves properly.

On the web, this works, I hear the music. On Android Chrome, the audio did not play:

Anybody out there know why?

Upvotes: 0

Views: 258

Answers (1)

codedread
codedread

Reputation: 1382

After a bunch of playing around and debugging, on a whim I finally removed some code I had planned to experiment with around audio context / graph:

const audioCtx = new AudioContext();
const sourceNode = audioCtx.createMediaElementSource(this.audioElem);

After remove these lines - the <audio> element played properly!

Upvotes: 0

Related Questions