39 lines
No EOL
1 KiB
JavaScript
39 lines
No EOL
1 KiB
JavaScript
(function(){
|
|
|
|
var SOUND_URL = "http://hifi-content.s3.amazonaws.com/caitlyn/production/pizzaTurntable/newBuiltMixl.wav";
|
|
var soundVolume = 0.015;
|
|
var loopTime = -1; // Loop for how long? -1 is always on.
|
|
var loopSound = SoundCache.getSound(SOUND_URL);
|
|
var injector = null;
|
|
var entityID = null;
|
|
var myProps = null;
|
|
|
|
this.preload = function(pEntityID) {
|
|
entityID = pEntityID;
|
|
var intervalID = Script.setInterval(function() {
|
|
myProps = Entities.getEntityProperties(entityID, ["position"]);
|
|
if (!injector) {
|
|
if (loopSound.downloaded) {
|
|
injector = Audio.playSound(loopSound, {
|
|
position: myProps.position,
|
|
volume: soundVolume,
|
|
loop: true,
|
|
localOnly: true
|
|
});
|
|
}
|
|
} else {
|
|
injector.setOptions({
|
|
position: myProps.position
|
|
});
|
|
}
|
|
}, 1000);
|
|
};
|
|
|
|
this.unload = function(){
|
|
if (injector !== undefined && injector.isPlaying) {
|
|
injector.stop();
|
|
injector = undefined;
|
|
}
|
|
};
|
|
|
|
}); |