repo: janusweb action: commit revision: path_from: revision_from: 0134037187549da725cfdb61cf97c996c04138f8: path_to: revision_to:
commit 0134037187549da725cfdb61cf97c996c04138f8 Author: James BaicoianuDate: Thu Sep 29 03:08:27 2016 -0700 Allow sound properties to be updated from scripts diff --git a/scripts/sound.js b/scripts/sound.js
--- a/scripts/sound.js
+++ b/scripts/sound.js
@@ -9,8 +9,8 @@ elation.require(['janusweb.janusbase'], function() {
auto_play: { type: 'boolean', default: false },
play_once: { type: 'boolean', default: false },
dist: { type: 'float', default: 1.0 },
- pitch: { type: 'float', default: 1.0 },
- gain: { type: 'float', default: 1.0 }
+ pitch: { type: 'float', default: 1.0, set: this.updateSound },
+ gain: { type: 'float', default: 1.0, set: this.updateSound }
});
Object.defineProperty(this, 'playing', { get: function() { if (this.audio) return this.audio.isPlaying; return false; } });
}
@@ -83,5 +83,18 @@ elation.require(['janusweb.janusbase'], function() {
this.audio.stop();
}
}
+ this.updateSound = function() {
+ if (this.audio) {
+ this.play();
+ this.audio.setVolume(this.gain);
+ }
+ }
+ this.getProxyObject = function() {
+ var proxy = elation.engine.things.janussound.extendclass.getProxyObject.call(this);
+ proxy._proxydefs = {
+ gain: [ 'property', 'gain'],
+ };
+ return proxy;
+ }
}, elation.engine.things.janusbase);
});
-----END OF PAGE-----