Valli
Valli

Reputation: 267

Event when <audio> begins playing

I want a gif loader image to disappear as soon as an autoplayed audio tag starts playing ie. after it loads. Is there any way to do this with javascript? The audio is a live stream if that matters.

Upvotes: 1

Views: 83

Answers (1)

Jezen Thomas
Jezen Thomas

Reputation: 13800

I think you're looking for the canplaythrough event.

audio.addEventListener('canplaythrough', function() { 
    audio.play();
    // code that removes your gif loader
}, false);

Upvotes: 1

Related Questions