]> _ Git - fluidbook-html5.git/commitdiff
wait #6566 @0.75
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 8 Dec 2023 16:17:55 +0000 (17:17 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 8 Dec 2023 16:17:55 +0000 (17:17 +0100)
js/libs/fluidbook/fluidbook.sound.js

index 641302b670146cd3b431ccfeb3f2757f2ddfa69a..8bde95df13d13c88527d409d0ad24886e606d000 100644 (file)
@@ -12,6 +12,12 @@ function FluidbookSound(fluidbook) {
     this.audios = {};
     this.playing = null;
     this.simpleTheme = this.fluidbook.settings.simpleSoundTheme;
+    this.volume = parseFloat(this.fluidbook.settings.soundVolume);
+    if (isNaN(this.volume)) {
+        this.volume = 100;
+    }
+    this.volume = Math.max(0, Math.min(100, this.volume)) / 100;
+    console.log(this.volume, this.fluidbook.settings.soundVolume);
 
     this.initEvents();
 }
@@ -57,7 +63,7 @@ FluidbookSound.prototype = {
                 src = 'data/sounds/' + v + '.mp3';
             }
             var s = new Audio($this.fluidbook.loader.getURL(src));
-            s.volume = 1;
+            s.volume = $this.volume;
             s.preload = 'auto';
             $this.audios[v] = s;
         })
@@ -128,7 +134,7 @@ FluidbookSound.prototype = {
         }
 
         try {
-            this.audios[sound].volume = 1;
+            this.audios[sound].volume = this.volume;
             if (this.audios[sound].fastSeek !== undefined) {
                 this.audios[sound].fastSeek(seek);
             } else {