// // ambiance.js // examples // // Created by Clément Brisset on 11/18/14. // Copyright 2014 High Fidelity, Inc. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // var soundURL = "https://hifi-public.s3.amazonaws.com/sounds/02%20Real%20Situation.stereo.raw"; var position = { x: 7747.8, y: 390.1, z: 9986.8}; var audioOptions = { position: position, volume: 0.02, loop: true, stereo: true }; var sound = SoundCache.getSound(soundURL, audioOptions.isStereo); var injector = null; var count = 100; Script.update.connect(function() { if (count > 0) { count--; return; } if (sound.downloaded && injector === null) { print("Sound downloaded."); injector = Audio.playSound(sound, audioOptions); print("Playing: " + injector); } }); Script.scriptEnding.connect(function() { if (injector !== null) { injector.stop(); } });