Fix music volume if not fadein

This commit is contained in:
Victor 2015-12-09 12:41:30 +02:00
parent 1624192002
commit f75031316c

View File

@ -393,6 +393,8 @@ Views.prototype.music = function (name, fade) {
if (fade.fadeIn) { if (fade.fadeIn) {
$(this.musicPlayerAudio).prop("volume", 0.0); $(this.musicPlayerAudio).prop("volume", 0.0);
$(this.musicPlayerAudio).animate({volume: 1.0}, fade.duration * 1000); $(this.musicPlayerAudio).animate({volume: 1.0}, fade.duration * 1000);
} else {
$(this.musicPlayerAudio).prop("volume", 1.0);
} }
} catch (e) { } catch (e) {
console.log("music: " + name + " " + e); console.log("music: " + name + " " + e);
@ -426,6 +428,8 @@ Views.prototype.sound = function (name, fade) {
if (fade.fadeIn) { if (fade.fadeIn) {
$(this.soundPlayerAudio).prop("volume", 0.0); $(this.soundPlayerAudio).prop("volume", 0.0);
$(this.soundPlayerAudio).animate({volume: 1.0}, fade.duration * 1000); $(this.soundPlayerAudio).animate({volume: 1.0}, fade.duration * 1000);
} else {
$(this.soundPlayerAudio).prop("volume", 1.0);
} }
} catch (e) { } catch (e) {
console.log("sound: " + name + " " + e); console.log("sound: " + name + " " + e);
@ -457,6 +461,8 @@ Views.prototype.soundLoop = function (name, fade) {
if (fade.fadeIn) { if (fade.fadeIn) {
$(this.soundLoopPlayerAudio).prop("volume", 0.0); $(this.soundLoopPlayerAudio).prop("volume", 0.0);
$(this.soundLoopPlayerAudio).animate({volume: 1.0}, fade.duration * 1000); $(this.soundLoopPlayerAudio).animate({volume: 1.0}, fade.duration * 1000);
} else {
$(this.soundLoopPlayerAudio).prop("volume", 1.0);
} }
} catch (e) { } catch (e) {
console.log("soundloop: " + name + " " + e); console.log("soundloop: " + name + " " + e);
@ -481,7 +487,6 @@ Views.prototype.ambience = function (name, fade) {
this.stopAmbience(this.ambiencePlayerAudio.fade); this.stopAmbience(this.ambiencePlayerAudio.fade);
this.ambiencePlayerAudio.src = PathResolver.ambience(name); this.ambiencePlayerAudio.src = PathResolver.ambience(name);
this.ambiencePlayerAudio.fade = fade; this.ambiencePlayerAudio.fade = fade;
var views = this;
this.ambiencePlayerAudio.addEventListener('ended', function () { this.ambiencePlayerAudio.addEventListener('ended', function () {
this.currentTime = 0; this.currentTime = 0;
this.play(); this.play();
@ -490,6 +495,8 @@ Views.prototype.ambience = function (name, fade) {
if (fade.fadeIn) { if (fade.fadeIn) {
$(this.ambiencePlayerAudio).prop("volume", 0.0); $(this.ambiencePlayerAudio).prop("volume", 0.0);
$(this.ambiencePlayerAudio).animate({volume: 1.0}, fade.duration * 1000); $(this.ambiencePlayerAudio).animate({volume: 1.0}, fade.duration * 1000);
} else {
$(this.ambiencePlayerAudio).prop("volume", 1.0);
} }
} catch (e) { } catch (e) {
console.log("ambience: " + name + " " + e); console.log("ambience: " + name + " " + e);