4

我正在使用 A-Frame,当我导入音频文件时,它们根本不播放。我已经在 Safari 和 Chrome 上尝试过,我使用的是 Oculus Go,在它的浏览器中可以看到游戏,但也没有音频。有什么建议么??

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>VR GAME 1</title>
    <meta name="description" content="VR GAME 1"/>
    <script src="https://aframe.io/releases/0.8.2/aframe.min.js"></script>
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto%7CRoboto+Mono" media="all"/>
   <script src="https://cdn.jsdelivr.net/npm/aframe-gif-shader@0.2.0/dist/aframe-gif-shader.min.js"></script>
   <script src="https://rawgit.com/mayognaise/aframe-gif-component/master/dist/aframe-gif-component.min.js"></script>

<body class="a-body ">
   <a-scene class="fullscreen" inspector="" keyboard-shortcuts="" screenshot="" vr-mode-ui="">


    <!--ASSETS-->
        <a-assets>
           <img id="robot" src="shooterrobot.gif">
           <img id="scared" src="scared.gif">
           <audio id="no" src="no.wav"></audio>
           <audio id="no" src="no.mp3"></audio>
    </a-assets>



    <!--CAMERA-->
    <a-camera camera="" position="0 0 600" rotation="" look-controls="" wasd-    controls="" data-aframe-inspector-original-camera="">
            <a-cursor material="" raycaster="" cursor="" geometry=""></a-cursor>
    </a-camera>


    <!--ANIMATED GIF-->
     <a-entity geometry="primitive:plane" position="+100 -300 0"     material="shader:gif;transparent:true;src:url(scared.gif);" gif="" scale="1000,     1000, 0"></a-entity>


     <!--AUDIO-->
     <a-audio src="no.wav" autoplay="true"></a-audio>
     <audio id="no" src="no.wav" preload="auto"></audio>
     <a-sound src="no" src="no.wav" autoplay="true"></a-sound>
     <a-sound id="no" crossorigin="anonymous" src="no.mp3"></a-sound>


    <!--CONTROLS-->
    <a-entity laser-controls="" daydream-controls="hand:right" gearvr-    controls="hand:right" oculus-touch-controls="hand:right" vive-    controls="hand:right" windows-motion-controls=""></a-entity>



     <a-sky src="1.jpg" rotation="0 0 0"></a-sky>


  </a-scene>
</body>
</html>
4

1 回答 1

3

语法不正确。它应该是

<a-sound src=“url(no.mp3)”&gt;<a-sound>

或在引用 a 资产时:

<a—sound src=“#no”&gt;<a-sound>

a-sound 文档

另请注意,您正在为 a-assets 中的音频元素和下面的 a-sound 分配相同的 ID。使这些 id 不同

于 2018-08-15T06:26:18.503 回答