Merge pull request #2774 from jagomf/patch-1
Recover default value for AnimationConfig's renderer
diff --git a/player/js/elements/AudioElement.js b/player/js/elements/AudioElement.js
index 6eda26c..fdd7fea 100644
--- a/player/js/elements/AudioElement.js
+++ b/player/js/elements/AudioElement.js
@@ -17,7 +17,11 @@
this.audio = this.globalData.audioController.createAudio(assetPath);
this._currentTime = 0;
this.globalData.audioController.addAudio(this);
+ this._volumeMultiplier = 1;
+ this._volume = 1;
+ this._previousVolume = null;
this.tm = data.tm ? PropertyFactory.getProp(this, data.tm, 0, globalData.frameRate, this) : { _placeholder: true };
+ this.lv = PropertyFactory.getProp(this, data.au && data.au.lv ? data.au.lv : {k: [100]}, 1, 0.01, this);
}
AudioElement.prototype.prepareFrame = function (num) {
@@ -29,6 +33,12 @@
} else {
this._currentTime = num / this.data.sr;
}
+ this._volume = this.lv.v[0];
+ var totalVolume = this._volume * this._volumeMultiplier;
+ if ( this._previousVolume != totalVolume ) {
+ this._previousVolume = totalVolume;
+ this.audio.volume(totalVolume);
+ }
};
extendPrototype([RenderableElement, BaseElement, FrameElement], AudioElement);
@@ -71,7 +81,9 @@
};
AudioElement.prototype.volume = function (volumeValue) {
- this.audio.volume(volumeValue);
+ this._volumeMultiplier = volumeValue;
+ this._previousVolume = volumeValue * this._volume;
+ this.audio.volume(this._previousVolume);
};
AudioElement.prototype.getBaseElement = function () {