AR.js 上没有播放声音😖

问题描述 投票:0回答:0

我一直在使用 AR.js 进行增强现实以获得 WebAR 体验,我需要播放触摸屏幕上 3d 对象的声音,但现在我不能,这是代码:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>Reproducción de sonido en AR.js</title>
    <script src="https://aframe.io/releases/1.2.0/aframe.min.js"></script>
    <script src="https://cdn.rawgit.com/jeromeetienne/AR.js/2.2.0/aframe/build/aframe-ar.js"></script>
    <script>
      function reproducirSonido() {
        var sonido = document.getElementById("sonido");
        sonido.play();
      }
    </script>
    <style>
      #marcador {
        position: absolute;
        top: 50%;
        left: 50%;
        width: 300px;
        height: 300px;
        margin-top: -150px;
        margin-left: -150px;
        background-color: white;
      }
    </style>
  </head>
  <body style="margin: 0px; overflow: hidden">
    <a-scene embedded arjs>
      <a-marker
        preset="custom"
        type="pattern"
        url="https://cdn.glitch.global/847d4754-7230-4eb5-baeb-1626c2b619be/marker.patt?v=1681415242369"
      >
        <a-entity
          gltf-model="https://cdn.glitch.global/847d4754-7230-4eb5-baeb-1626c2b619be/tecla001.gltf?v=1681415241911"
          scale="0.5 0.5 0.5"
          position="0 0 0"
          rotation="0 45 0"
          onclick="reproducirSonido()"
        ></a-entity>
      </a-marker>
      <a-entity camera></a-entity>
    </a-scene>
    <audio
      id="sonido"
      src="https://cdn.glitch.global/847d4754-7230-4eb5-baeb-1626c2b619be/Funny_Scream.ogg?v=1681423344830"
    ></audio>
  </body>
</html>

如果你愿意,你可以试试Glitch网站的例子这个例子的图案是经典的AR黑色方块。 有什么建议或想法吗? 🤔 请评论。

为对此主题感兴趣的任何人展示和学习使用 AR.js 的 WebAR 的新体验。

javascript html augmented-reality interactive ar.js
© www.soinside.com 2019 - 2024. All rights reserved.