From: Vincent Vanwaelscappel Date: Mon, 13 Nov 2017 16:07:56 +0000 (+0100) Subject: fix #1793 @1.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=57de49765b69da72a20fca6e73d9366706aa8619;p=fluidbook-html5.git fix #1793 @1.5 --- diff --git a/_index.html b/_index.html index 5f9efb9e..23ad3072 100644 --- a/_index.html +++ b/_index.html @@ -87,6 +87,7 @@
+ \ No newline at end of file diff --git a/js/libs/fluidbook/fluidbook.nav.js b/js/libs/fluidbook/fluidbook.nav.js index 25d72c07..f1ce4ffc 100644 --- a/js/libs/fluidbook/fluidbook.nav.js +++ b/js/libs/fluidbook/fluidbook.nav.js @@ -10,6 +10,7 @@ function FluidbookNav(fluidbook) { this._inited = {}; this.setNav('horizontalNav'); this.setNav('menu'); + } FluidbookNav.prototype = { diff --git a/js/libs/fluidbook/fluidbook.sound.js b/js/libs/fluidbook/fluidbook.sound.js index 4ff37f9e..0c6b73f7 100644 --- a/js/libs/fluidbook/fluidbook.sound.js +++ b/js/libs/fluidbook/fluidbook.sound.js @@ -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 index 00000000..fed8dc60 Binary files /dev/null and b/sound/empty.mp3 differ