音频无法在 A-Frame 中播放
Audio won't play in A-Frame
我正在使用 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>
语法不正确。应该是
<a-sound src=“url(no.mp3)”><a-sound>
或引用 a 资产时:
<a—sound src=“#no”><a-sound>
另请注意,您为下面的 a-assets 和 a-sound 中的两个音频元素分配了相同的 ID。使这些 ID 不同
我正在使用 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>
语法不正确。应该是
<a-sound src=“url(no.mp3)”><a-sound>
或引用 a 资产时:
<a—sound src=“#no”><a-sound>
另请注意,您为下面的 a-assets 和 a-sound 中的两个音频元素分配了相同的 ID。使这些 ID 不同