Skip to content

Commit

Permalink
Merge 393fe6a into a08c347
Browse files Browse the repository at this point in the history
  • Loading branch information
dalgwen authored Aug 20, 2023
2 parents a08c347 + 393fe6a commit 26fca17
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions bundles/org.openhab.ui/web/src/components/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ export default {
ready: false,
eventSource: null,
audioContext: null,
audioSources: new Map(),
// Framework7 Parameters
f7params: {
Expand Down Expand Up @@ -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') {
Expand All @@ -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)
})
})
Expand Down

0 comments on commit 26fca17

Please sign in to comment.