35 lines
No EOL
1,001 B
JavaScript
35 lines
No EOL
1,001 B
JavaScript
// audio test - davedub - jan 2016
|
|
|
|
var wavFile = SoundCache.getSound("https://hifi-content.s3.amazonaws.com/dave/walk-beta/assets/animation-sets/male-two/sounds/FootstepW2Right-12db.wav");
|
|
var audioInjector = null;
|
|
var options = {
|
|
position: MyAvatar.position,
|
|
volume: 1
|
|
};
|
|
var frequency = 1.0;
|
|
var elapsedTime = 0;
|
|
|
|
Script.update.connect(function(deltaTime) {
|
|
|
|
elapsedTime += deltaTime;
|
|
|
|
if (elapsedTime > frequency) {
|
|
|
|
try {
|
|
|
|
if (audioInjector) {
|
|
print('restarting audio injector');
|
|
audioInjector.setOptions(options);
|
|
audioInjector.restart();
|
|
} else {
|
|
print('creating audio injector');
|
|
audioInjector = Audio.playSound(wavFile, options);
|
|
}
|
|
elapsedTime = 0;
|
|
|
|
} catch (e) {
|
|
|
|
print('Error whilst trying to play sounds: '+e.toString());
|
|
}
|
|
}
|
|
}); |