0

I'm trying to add in some music to a landing page on my website, the file is called "LandingPageMusic.mp3" and it is in a separate folder called "Music". When I insert the following code into the body of the page, no music plays - I am using Google Chrome FYI.

<embed src="LandingPageMusic.mp3" autostart="true" loop="true">
  • Possible duplicate of [How to make audio autoplay on chrome](https://stackoverflow.com/questions/50490304/how-to-make-audio-autoplay-on-chrome) – John Montgomery Sep 27 '19 at 22:16

2 Answers2

0

If you use HTML5, you can use <audio> now:

<audio autoplay loop style="display:none;">
  <source src="LandingPageMusic.mp3" type="audio/mp3">
</audio>

This should give you an audio player that autoplays, and style will hide the player.

CEH
  • 5,701
  • 2
  • 16
  • 40
  • Thanks, this worked but I want the music to automatically play and for there to be no player. How would I do this? –  Sep 27 '19 at 22:19
  • 1
    @Harry I've updated my answer with the `autoplay` attribute, `loop` attribute, and a `style="display:none;` attribute to hide the player. – CEH Sep 27 '19 at 22:21
0

try that :

<audio autostart loop>
      <source src = "LandingPageMusic.mp3">
</audio>
Escanor
  • 95
  • 3
  • 9