在我尝试在A帧场景中播放A声音的第二时间,Safari抛出InvalidStateError:
标记:
<a-sound
id="halloween2018-sound"
src="/sounds/halloween2018-funny.mp3"
autoplay="false"
loop="true"
soundhandler
>
</a-sound>
Javascript:
AFRAME.registerComponent('soundhandler', {
tick: function () {
var soundEntity = this.el;
if (markerGotVisible && !soundEntity.components.sound.isPlaying) {
soundEntity.components.sound.playSound();
}
else if(markerGotHidden && soundEntity.components.sound.isPlaying){
soundEntity.components.sound.pauseSound();
}
}
}