首页 > 解决方案 > Aframe 音频问题

问题描述

我在我的场景中包含了以下音频资产。两种方式都试过了......

<audio id="hover" src="resources/assets_data/hover.mp3"></audio>

<a-asset-item id="hover" src="resources/assets_data/hover.mp3" response-type="arraybuffer"></a-asset-item>

当我尝试在四个菜单元素中播放此声音时,我遇到了错误...并且悬停声音仅在第一个菜单弯曲图像上播放...。

组件:声音:警告声音尚未加载。加载完成后播放

代码:

<a-curvedimage  src="#a" transparent="true" 
                height="0.5" radius="0.9" theta-length="40" rotation="0 240 0" position="0 1.74 -1.4" sound="on: mouseenter; src: #hover" selectable>
        </a-curvedimage>

        <a-curvedimage src="#b" transparent="true" 
                height="0.5" radius="0.9" theta-length="40" rotation="0 190 0" position="0 1.74 -1.4" sound="on: mouseenter; src: #hover" selectable>
        </a-curvedimage>

        <a-curvedimage src="#c" transparent="true" 
                height="0.5" radius="0.9" theta-length="40" rotation="0  130 0" position="0 1.74 -1.4" sound="on: mouseenter; src: #hover" selectable>
        </a-curvedimage>

        <a-curvedimage src="#d" transparent="true" 
                height="0.5" radius="0.9" theta-length="40" rotation="0  80 0" position="0 1.74 -1.4" sound="on: mouseenter; src: #hover" selectable>
        </a-curvedimage>

标签: aframe

解决方案


preload: auto当我使用具有以下属性的音频标签时似乎正在工作:

<a-assets>
   <audio id="mysound" crossorigin="anonymous" src="...">
</a-assets>

在这里试试。


推荐阅读