0

I'm trying to make a background music .I tried few code which are available but it didn't work for me .I can play it by clicking the play button but i want it to play automatically i want to make it as background music ...

I am using chrome but it still not working here

I want you guys to change or update my code ...please

<!DOCTYPE html>
<htlm>

  <head>
    <title>test</title>
    <mata charaset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
      <link rel="stylesheet" href="cv.css">
      <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
      <script src="https://kit.fontawesome.com/a54d2cbf95.js"></script>

  </head>

  <style>

  </style>

  <body>
    <audio controls autoplay>
        <!-- <source src="horse.ogg" type="audio/ogg"> -->
        <source src="backsound.mp3" type="audio/mpeg">
        Your browser does not support the audio element.
      </audio>




    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>

  </body>
</htlm>
shahmir
  • 15
  • 5
  • 2
    Does this answer your question? [How to make audio autoplay on chrome](https://stackoverflow.com/questions/50490304/how-to-make-audio-autoplay-on-chrome) – Maxim Mazurok May 10 '20 at 02:29
  • BTW it's `html` not `htlm` :-) – user2740650 May 10 '20 at 02:31
  • I check this but it didn't work @MaximMazurok – shahmir May 10 '20 at 02:33
  • It's generally a bad idea to start playing music when you open a website. Imagine that you are in the office and don't want to interrupt your colleagues by accidentally opening some website. That's why browsers fight this and make it more and more difficult to do. The general idea is that user have to interact with your website first before it can play music or video. You can make a pop-up asking user if he wants to enable music or not. When he clicks yes - start playing. – Maxim Mazurok May 10 '20 at 02:43
  • @MaximMazurok what if I play soft and slow volume music – shahmir May 10 '20 at 07:51
  • And how the browser is supposed to know what kind of music you're playing? As far as the browser concerned, mozart.mp3 could be a death metal rock. I might be watching a video in another window, or my baby might be asleep right next to me. Just be nice and ask the user, please. Cheers! – Maxim Mazurok May 10 '20 at 10:39
  • ok I get your point I am not inserting it thank you – shahmir May 11 '20 at 21:06

0 Answers0