I want to determine when the sound ends, but all the examples that I found are not working.
var sound1 = new THREE.PositionalAudio( listener );
sound1.load( 'sounds/Example.ogg' );
sound1.setRefDistance( 30 );
sound1.autoplay = false;
sound1.setLoop(false);
mesh1.add( sound1 );
setTimeout(function() {
sound1.play();
}, 2000);
sound1.onended = function() {
console.log('sound1 ended #1');
};
sound1.addEventListener('ended', function() {
console.log('sound1 ended #2');
});
Live example: http://codepen.io/anon/pen/wMRoWQ
source
share