From 154aaac5a6f97f37a2e8af96650824a44e1b71d9 Mon Sep 17 00:00:00 2001 From: Piotr Dabrowski Date: Mon, 15 Jul 2013 14:36:47 +0200 Subject: [PATCH] [Piano] updated Piano sources Change-Id: I78648f109ae5f9af36f2b3692ee3d3f794c81b3f --- js/main.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/js/main.js b/js/main.js index fbbec59..986eb8a 100644 --- a/js/main.js +++ b/js/main.js @@ -52,6 +52,12 @@ function Piano() { $('#back').bind('touchend', function (event) { $(this).removeClass('active'); }); + + document.addEventListener('webkitvisibilitychange', function () { + if (document.webkitVisibilityState === 'visible') { + self.audioInit() + } + }) }; Piano.prototype.onPianoKeyTouchDown = function onPianoKeyTouchDown(data) { @@ -107,8 +113,12 @@ function Piano() { this.touchPianoKey[touchId] = element.id; if (this.audio[nrAudio]) { if (this.audio[nrAudio].src) { - this.audio[nrAudio].pause(); - this.audio[nrAudio].currentTime = 0; + try { + this.audio[nrAudio].pause(); + this.audio[nrAudio].currentTime = 0; + } catch (err) { + console.error(err); + } } else { this.audio[nrAudio].src = this.audio[nrAudio].name + ".wav"; } -- 2.7.4