does not kick start when marker is detected

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

我是java脚本和html的新手,我就这么堆叠了。以下是我编写的内容,并希望在检测到标记时启动原始内容。但是,当我在浏览器上访问html时,声音会立即启动。

   <a-marker type="pattern" url="pat/ban.patt">
      <a-entity>
         <a-image id="obj0" rotation="-90 0 0" src="#banto" width="5" height="5"></a-image>
         <a-entity position="-0.75 1 1" rotation="-90 0 0" text-geometry="value: Head of the cleark; bevelEnabled: false; bevelSize: 0.008; bevelThickness: 0.08; size: 0.25;" material="color: cyan;"></a-entity>
         <a-sound src="#bantoSound" autoplay="true"></a-sound>
      </a-entity>
    </a-marker>

虽然仅在检测到标记时显示....

不能像???一样工作

image audio aframe
1个回答
0
投票

我担心只要实体加载到DOM中,autoplay:true就会发出声音。

我建议您禁用自动播放,或在场景加载时停止所有声音,并在标记可见时激活它:

if(document.querySelector("a-marker").object3D.visible == true){
  // play the sound
}
© www.soinside.com 2019 - 2024. All rights reserved.