mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 03:44:02 +02:00
fixes for new injector API in other scripts
This commit is contained in:
parent
d8646f6ea0
commit
f9174366dc
6 changed files with 12 additions and 10 deletions
|
@ -117,7 +117,7 @@
|
|||
print("stopSound()");
|
||||
}
|
||||
if (this.injector) {
|
||||
Audio.stopInjector(this.injector);
|
||||
this.injector.stop();
|
||||
this.injector = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,14 +75,14 @@ function maybePlaySound(deltaTime) {
|
|||
//print("number playing = " + numPlaying);
|
||||
}
|
||||
for (var i = 0; i < playing.length; i++) {
|
||||
if (!Audio.isInjectorPlaying(playing[i].audioId)) {
|
||||
if (!playing[i].audioId.isPlaying) {
|
||||
Entities.deleteEntity(playing[i].entityId);
|
||||
if (useLights) {
|
||||
Entities.deleteEntity(playing[i].lightId);
|
||||
}
|
||||
playing.splice(i, 1);
|
||||
} else {
|
||||
var loudness = Audio.getLoudness(playing[i].audioId);
|
||||
var loudness = playing[i].audioId.loudness;
|
||||
var newColor = { red: playing[i].color.red, green: playing[i].color.green, blue: playing[i].color.blue };
|
||||
if (loudness > 0.05) {
|
||||
newColor.red *= (1.0 - loudness);
|
||||
|
|
|
@ -21,7 +21,7 @@ var offset = Vec3.normalize(Quat.getFront(MyAvatar.orientation));
|
|||
var position = Vec3.sum(MyAvatar.position, offset);
|
||||
|
||||
function update(deltaTime) {
|
||||
if (!Audio.isInjectorPlaying(soundPlaying)) {
|
||||
if (!soundPlaying.isPlaying) {
|
||||
soundPlaying = Audio.playSound(sound, {
|
||||
position: position,
|
||||
loop: true
|
||||
|
@ -31,7 +31,7 @@ function update(deltaTime) {
|
|||
}
|
||||
|
||||
function scriptEnding() {
|
||||
if (Audio.isInjectorPlaying(soundPlaying)) {
|
||||
if (soundPlaying.isPlaying) {
|
||||
Audio.stopInjector(soundPlaying);
|
||||
print("Stopped sound loop");
|
||||
}
|
||||
|
|
|
@ -32,14 +32,14 @@ var sound = Audio.playSound(soundClip, { position: orbitCenter, loop: true, volu
|
|||
function update(deltaTime) {
|
||||
time += deltaTime;
|
||||
currentPosition = { x: orbitCenter.x + Math.cos(time * SPEED) * RADIUS, y: orbitCenter.y, z: orbitCenter.z + Math.sin(time * SPEED) * RADIUS };
|
||||
trailingLoudness = 0.9 * trailingLoudness + 0.1 * Audio.getLoudness(sound);
|
||||
trailingLoudness = 0.9 * trailingLoudness + 0.1 * sound.loudness;
|
||||
Entities.editEntity( objectId, { position: currentPosition, color: { red: Math.min(trailingLoudness * 2000, 255), green: 0, blue: 0 } } );
|
||||
Audio.setInjectorOptions(sound, { position: currentPosition });
|
||||
sound.setOptions({ position: currentPosition });
|
||||
}
|
||||
|
||||
Script.scriptEnding.connect(function() {
|
||||
Entities.deleteEntity(objectId);
|
||||
Audio.stopInjector(sound);
|
||||
sound.stop();
|
||||
});
|
||||
|
||||
Script.update.connect(update);
|
|
@ -45,8 +45,8 @@ function maybePlaySound(deltaTime) {
|
|||
}
|
||||
|
||||
function scriptEnding() {
|
||||
if (Audio.isInjectorPlaying(soundPlaying)) {
|
||||
Audio.stopInjector(soundPlaying);
|
||||
if (soundPlaying.isPlaying) {
|
||||
soundPlaying.stop();
|
||||
Entities.deleteEntity(ball);
|
||||
print("Stopped sound.");
|
||||
}
|
||||
|
|
|
@ -27,6 +27,8 @@ class AbstractAudioInterface;
|
|||
|
||||
class AudioInjector : public QObject {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool isPlaying READ isPlaying)
|
||||
Q_PROPERTY(float loudness READ getLoudness)
|
||||
public:
|
||||
AudioInjector(QObject* parent);
|
||||
AudioInjector(Sound* sound, const AudioInjectorOptions& injectorOptions);
|
||||
|
|
Loading…
Reference in a new issue