Задать вопрос

Как добавить в HTML страницу воспроизведение музыки?

Доброго времени суток. Имеется такая HTML страничка

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <script type="text/javascript">
    function DivFlying() {
      var div = document.getElementById("divFly");
      if (!div) {
        return;
      }
      if(window.event.clientX<=0||window.event.clientY<=0){
        div.style.display = "none";
      }
      else{
        div.style.display = "block";
        var intX = window.event.clientX-100;
        var intY = window.event.clientY-100;
        div.style.left = intX + "px";
        div.style.top = intY + "px";
        console.log(intX+","+intY);
      }
    }
    // document.onmousemove = DivFlying;
    document.onmousemove = DivFlying
    document.onmouseleave = DivFlying
  </script>
  <style type="text/css">
    .main{
      text-align: center;
      width: auto;
      height: auto;
    }
    .background{
      width: 100%;
      height: 100%;
      position: absolute;
      top: 0px;
      bottom: 0px;
      left: 0px;
      right: 0px;
	  background-size: contain;
	  overflow: hidden
    }
    .front{
      width: 100%;
      height: 100%;
      position: absolute;
      top: 0px;
      bottom: 0px;
      left: 0px;
      right: 0px;
      background-image: url("0.jpg");
      background-position: center;
	  background-size: contain;
	  overflow: hidden
    }
    #divFly{
      width: 200px;
      height: 200px;
      border-radius: 50%;
      box-shadow: 0px 0px 100px rgba(0,0,0,0.5);
      overflow: hidden;
      display: none;
    }
    .inner{
      position: absolute;
      width: 200px;
      height: 200px;
      background-image: url("1.jpg");
      background-attachment: fixed;
      background-position: center;
	  background-size: contain;
	  overflow: hidden
    }
  </style>
</head>
<body>
  <div class="main">
    <div class="background">
      <div class="front"/>
      <div id="divFly" style="position:absolute;">
        <div class="inner"></div>
      </div>
    </div>
  </div>
</body>
</html>


Мне нужно что бы при открытии этой страницы играла зацикленная фоновая музыка. Что нужно добавить в этот код и куда что бы некий music.mp3 наконец заиграл? В интернете я нашел много примеров на чистом html и на js но что бы я не пробовал, браузер молчит...
  • Вопрос задан
  • 92 просмотра
Подписаться 1 Средний 4 комментария
Решения вопроса 1
@alexalexes
Это заблокировано на уровне политик браузера - аудио не должно включаться, если пользователь явно не нажал воспроизведение.
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы