Amad Khan
Amad Khan

Reputation: 19

Why does my JavaScript Audio Autoplay not work?

When a user visits my website music should start playing automatically. The user does not need to click on a button. Users just visit my site, the page will be loaded, and the audio will start automatically.

I was trying using below code, but it is not working.

W3 Schools audio auto play

Please help me to understand why this doesn't work?

When the user visits my site the music should be automatically started. They shouldn't be able to stop the music. After playing the full track it should not repeat.

Upvotes: 0

Views: 501

Answers (1)

Amin Fazlali
Amin Fazlali

Reputation: 1237

In some devices like smart phones, videos and audios only will play by user generated events like click and ...

If you play audio on page loading event it does not work in some device. But playing audio on page loading will works properly in PCes browsers.

Upvotes: 1

Related Questions