Aframe自帶的Sound Component

Example:

<a-entity id="river" geometry="primitive: plane" material="color: blue"
position="-10 0 0" sound="src: url(river.mp3); autoplay: true"></a-entity

上方的程式碼中,我們宣告了一個id為river的entity(entity可以是任何東西)。它的外觀是一個藍色(color:blue)的平面(plane)。他的位置在x軸的-10(橫坐標),y軸的0(縱坐標,也就是高度),z軸的0(深度). src是目標文件地址。 autoplay是自動播放。

aframe中聲音的常用指令包括:

sound compoenet有三種存在狀態:暫停,播放和停止。

這三種方式將結合events效果,就是互動或者動畫。

events主要有兩種狀態: sound-loaded和sound-ended。 前者是triggered when a sound file is loaded. 後者是triggered when sound finishes playing.