content/hifi-public/scripts/tests/injectorTest.js
Dale Glass 0d14e5a379 Initial data.
Needs a lot of cleanup. Data has been de-duplicated, and where identical copies existed, one of them
has been replaced with a symlink.

Some files have been excluded, such as binaries, installers and debug dumps. Some of that may still
be present.
2022-02-13 18:59:11 +01:00

42 lines
1.1 KiB
JavaScript

//
// injectorTests.js
// examples
//
// Created by Stephen Birarda on 11/16/15.
// 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 = "http://hifi-public.s3.amazonaws.com/birarda/medium-crowd.wav";
var audioOptions = {
position: { x: 0.0, y: 0.0, z: 0.0 },
volume: 0.5
};
var sound = SoundCache.getSound(soundURL);
var injector = null;
var restarting = false;
Script.update.connect(function(){
if (sound.downloaded) {
if (!injector) {
injector = Audio.playSound(sound, audioOptions);
} else if (!injector.isPlaying && !restarting) {
restarting = true;
Script.setTimeout(function(){
print("Calling restart for a stopped injector from script.");
injector.restart();
}, 1000);
} else if (injector.isPlaying) {
restarting = false;
if (Math.random() < 0.0001) {
print("Calling restart for a running injector from script.");
injector.restart();
}
}
}
})