diff --git a/bundles/org.openhab.ui/web/src/components/app.vue b/bundles/org.openhab.ui/web/src/components/app.vue index 91e651a28b..58d82b2eea 100644 --- a/bundles/org.openhab.ui/web/src/components/app.vue +++ b/bundles/org.openhab.ui/web/src/components/app.vue @@ -291,6 +291,7 @@ export default { ready: false, eventSource: null, audioContext: null, + audioSources: new Map(), // Framework7 Parameters f7params: { @@ -631,6 +632,13 @@ export default { }, playAudioUrl (audioUrl) { try { + if (audioUrl === '') { + this.audioSources.forEach(function (value, key) { + value.stop(0) + }) + this.audioSources.clear() + return + } if (!this.audioContext) { window.AudioContext = window.AudioContext || window.webkitAudioContext if (typeof (window.AudioContext) !== 'undefined') { @@ -644,6 +652,12 @@ export default { let source = this.audioContext.createBufferSource() source.buffer = buffer source.connect(this.audioContext.destination) + let customId = Date.now().toString() + this.audioSources.set(customId, source) + source.onended = () => { + source.stop(0) + this.audioSources.delete(customId) + } source.start(0) }) })