59 lines
1.7 KiB
JavaScript
59 lines
1.7 KiB
JavaScript
(function(){
|
|
|
|
// 37.3 / -10.5 / 53.6
|
|
var _entityId,
|
|
_currentProps,
|
|
_userData,
|
|
_soundURL,
|
|
soundPlaying = null,
|
|
position,
|
|
isSoundPlay = null,
|
|
soundObject;
|
|
|
|
|
|
function Sound_Zone_Client(){
|
|
|
|
}
|
|
|
|
Sound_Zone_Client.prototype = {
|
|
preload: function(id){
|
|
_entityId = id;
|
|
_currentProps = Entities.getEntityProperties(id);
|
|
_userData = JSON.parse(_currentProps.userData);
|
|
_soundURL = _userData.soundURL;
|
|
console.log("_soundURL", _soundURL)
|
|
position = _currentProps.position;
|
|
console.log("loadingSound")
|
|
soundObject = SoundCache.getSound(_soundURL);
|
|
console.log("soundObject", soundObject)
|
|
console.log(JSON.stringify(soundObject));
|
|
|
|
},
|
|
collisionWithEntity: function(myID, otherID, collisionInfo) {
|
|
this.playSound();
|
|
|
|
},
|
|
playSound: function(position){
|
|
console.log("playingSound")
|
|
var started = false;
|
|
if (!soundObject.downloaded){
|
|
return;
|
|
}
|
|
if (soundPlaying === null){
|
|
console.log( console.log("playingSound"))
|
|
soundPlaying = Audio.playSound(soundObject,{
|
|
position: position,
|
|
volume: 1.0,
|
|
loop: false
|
|
});
|
|
started = true;
|
|
} else if(!soundPlaying.playing) {
|
|
soundPlaying.restart();
|
|
started = true;
|
|
}
|
|
|
|
}
|
|
};
|
|
|
|
return new Sound_Zone_Client();
|
|
});
|