user2591042
user2591042

Reputation:

JavaScript preload Audio

I'm new to JavaScript, but I know, that I could set and play some audio file with this code:

player.src = "somefile.mp3";
player.play();

Where "player" is id of my audio tag. My question is: how can I preload the song? Because when I click on button, it plays after 3s delay...

Upvotes: 2

Views: 1083

Answers (1)

karaxuna
karaxuna

Reputation: 26940

Audio element has preload attribute:

<audio preload="auto|metadata|none"> // auto in your case

Upvotes: 2

Related Questions