Jump to content

How to autoplay mp3 song on home page?

Recommended Posts

  • Replies 5
  • Views 6.7k
  • Created
  • Last Reply
  • 1 month later...

@Soredadux

One way to do this is to add a code block and enter the following code.

<audio controls autoplay>

  <source src="[enter your MP3 file url here]" type="audio/mpeg">
  
  Your browser does not support the audio element.
  
  </audio>

Replace the [enter your MP3 file URL here] with the URL for your MP3 file.

If you have different versions of the audio files for playability on a wider range of platforms you can add source tags

 <source src="" type="audio/ogg">

See HTML <audio> Tag < https://www.w3docs.com/learn-html/html-audio-tag.html > for more info.

Let us know how it goes.

Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects.

Link to comment
2 hours ago, creedon said:

One way to do this is to add a code block and enter the following code.


<audio controls autoplay>

  <source src="[enter your MP3 file url here]" type="audio/mpeg">
  
  Your browser does not support the audio element.
  
  </audio>

Replace the [enter your MP3 file URL here] with the URL for your MP3 file.

If you have different versions of the audio files for playability on a wider range of platforms you can add source tags

 <source src="" type="audio/ogg">

See HTML <audio> Tag < https://www.w3docs.com/learn-html/html-audio-tag.html > for more info.

Let us know how it goes.

Hi! It was the first thing I've tried, but doesn't work on smartphones and I really don't know how to style it. Right now I have this code:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
    //var buttons = document.getElementsByClassName("play-button");
      console.log("1");
    //setTimeout(function(){
      $(".sqs-block-code").click(function() {
      $(".play").click();
      $(".sqs-block-code").off();
    });
    //},3000);
  
    //setTimeout(function(){ $(".play").click(); }, 3000);
});
</script>

The things is that works only if you make "click" on the page (anywhere).

Link to comment

@Soredadux

Please post the URL for the page where you want to auto play the audio.

If your site is not public please set up a site-wide password, if you've not already done so. Post the password here.

Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects.

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.