]> _ Git - fluidbook-html5.git/commitdiff
fix #1793 @1.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 13 Nov 2017 16:07:56 +0000 (17:07 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 13 Nov 2017 16:07:56 +0000 (17:07 +0100)
_index.html
js/libs/fluidbook/fluidbook.nav.js
js/libs/fluidbook/fluidbook.sound.js
sound/empty.mp3 [new file with mode: 0644]

index 5f9efb9e69712a6b526cc000731ffa2f6f80ff95..23ad3072bb0415002573999e3bd53dba2b83c45c 100644 (file)
@@ -87,6 +87,7 @@
 <div id="hiddencontents"><!-- $hiddenContents --></div>
 <div id="splash"><!-- $splash --></div>
 <div id="popinOverlay"></div>
+<audio src="sound/empty.mp3" id="pagesaudio" preload="auto"></audio>
 <!-- $statsfooter -->
 </body>
 </html>
\ No newline at end of file
index 25d72c0738ff91c08cac0ceea1ac2df4ea73ff42..f1ce4ffca99207d9c1607251248d20c943e0c6c5 100644 (file)
@@ -10,6 +10,7 @@ function FluidbookNav(fluidbook) {
     this._inited = {};
     this.setNav('horizontalNav');
     this.setNav('menu');
+
 }
 
 FluidbookNav.prototype = {
index 4ff37f9eea39e2d968d0e04fc7c5405fb80e182a..0c6b73f7c65424904d67546043bd9e4cdd14232b 100644 (file)
@@ -9,7 +9,7 @@ function FluidbookSound(fluidbook) {
 
     this.enabled = true;
     this.on = !!this.fluidbook.datas.soundOn;
-    this.audios = [];
+    this.audio = $("#pagesaudio").get(0);
     this.initEvents();
 }
 
@@ -27,6 +27,16 @@ FluidbookSound.prototype = {
         $(this.fluidbook).on('fluidbook.page.change.start', function (e, page, data) {
             $this.playSoundForPage(data);
         });
+
+        $(document).one('click', '*', function () {
+            $this.audio.src = 'sound/empty.mp3';
+            $this.audio.volume = 1;
+            try {
+                $this.audio.play();
+            } catch (e) {
+            }
+            return true;
+        });
     },
 
     init: function () {
@@ -82,22 +92,20 @@ FluidbookSound.prototype = {
             sound = 'page-flip-' + (Math.round(Math.random() + 1));
         }
 
-        var audio = new Audio('data/sounds/' + sound + '.mp3');
-        audio.volume = 1;
-        audio.play();
+        this.audio.src = 'data/sounds/' + sound + '.mp3';
+        this.audio.volume = 1;
+        try {
+            this.audio.play();
+        } catch (e) {
 
-        this.audios.push(audio);
+        }
     },
 
     stopAllSounds: function () {
-        $.each(this.audios, function (k, audio) {
-            try {
-                audio.pause();
-            } catch (err) {
+        try {
+            this.audio.pause();
+        } catch (e) {
 
-            }
-            audio = null;
-        });
-        this.audios = [];
+        }
     },
 };
\ No newline at end of file
diff --git a/sound/empty.mp3 b/sound/empty.mp3
new file mode 100644 (file)
index 0000000..fed8dc6
Binary files /dev/null and b/sound/empty.mp3 differ