Home > database >  MP3 audio player HTML
MP3 audio player HTML

Time:05-09

I'm creating a website using wordpress and I'm trying to add a MP3 music into it.

But the music don't autoplay on mobile. And when I click on pause, the music stop, but if I scroll (on PC or mobile) the music start again and again and again.

Here the html code :

<figure>
<audio
    controls
    src="https://www.blog-motivation.com/wp-content/uploads/2022/04/ولنبلونكم-بشئ-من-الخوف-والجوع-ونقص-من-الاموال-والانفس-والثمرات-وبشر-الصابرين-اسلام-صبحي.mp3" autoplay>
  
</audio>

thank you

CodePudding user response:

It is to not use autoplay because it could disturb some peoples, but if you want your audio with autoplay it is better to put source to another tag like this:

<audio controls autoplay>
  <source src="https://www.blog-motivation.com/wp-content/uploads/2022/04/ولنبلونكم-بشئ-من-الخوف-والجوع-ونقص-من-الاموال-والانفس-والثمرات-وبشر-الصابرين-اسلام-صبحي.mp3" type="audio/mpeg">
  Your browser does not support the audio element.
</audio>

It is also possible that your bowser is Chrome and this browser blocs automatically autoplay. To control autoplay in Chrome go here.

CodePudding user response:

Refer here : Audio Tag Autoplay Not working in mobile

Seems autoplay in chrome we need to use resume. it works in Firefox / chrome and target mobile / browser devices.

  • Related