2017-08-09 55 views
0

我是非常新的Java腳本和HTML,我非常喜歡這個。 以下是我編寫並希望在檢測到標記時啓動的基本操作。 但是,當我在瀏覽器上訪問html時,聲音就開始了。<a-sound>沒有踢開始時,檢測到標記

<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> 

雖然檢測到標記只有當被顯示....

不作爲如相同工作???

回答

0

恐怕autoplay:true會在實體加載到DOM時觸發聲音。

我建議你禁用自動播放,或停止所有聲音的現場負載時,和您激活它當光標是可見的:

if(document.querySelector("a-marker").object3D.visible == true){ 
    // play the sound 
} 
+0

非常感謝你爲你的海量幫助一次。所以我應該附加這個腳本,當我抓到標記時,聲音就會播放。我知道了。謝謝!!! –

+0

@KkMm如果你沒有進一步的問題可以隨時標記anwser :) –