Skip to content

Commit

Permalink
Fix linting
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
  • Loading branch information
florian-h05 committed Mar 7, 2023
1 parent a8e1d12 commit b32d519
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions bundles/org.openhab.ui/web/src/components/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -626,24 +626,24 @@ export default {
},
playAudioUrl (audioUrl) {
try {
if(!this.context){
if (!this.context) {
window.AudioContext = window.AudioContext || window.webkitAudioContext
if (typeof (window.AudioContext) !== 'undefined') {
this.context = new AudioContext()
unlockAudioContext(this.context);
unlockAudioContext(this.context)
}
}
let context = this.context
console.log('Playing audio URL: ' + audioUrl)
this.$oh.api.getPlain(audioUrl, '', '*/*', 'arraybuffer').then((data) => {
context.decodeAudioData(data, function (buffer) {
context.decodeAudioData(data, (buffer) => {
let source = context.createBufferSource()
source.buffer = buffer
source.connect(context.destination)
source.onended = function () {
context.suspend()
}
if(context.state == 'suspended'){
if (context.state === 'suspended') {
context.resume()
}
source.start(0)
Expand All @@ -655,15 +655,15 @@ export default {
this.context.suspend()
}
}
//Safari requires a touch event after the stream has started, hence this workaround
//Credit: https://www.mattmontag.com/web/unlock-web-audio-in-safari-for-ios-and-macos
function unlockAudioContext(audioCtx) {
if (audioCtx.state !== 'suspended') return;
const b = document.body;
const events = ['touchstart','touchend', 'mousedown','keydown'];
events.forEach(e => b.addEventListener(e, unlock, false));
function unlock() { audioCtx.resume().then(clean); }
function clean() { events.forEach(e => b.removeEventListener(e, unlock)); }
// Safari requires a touch event after the stream has started, hence this workaround
// Credit: https://www.mattmontag.com/web/unlock-web-audio-in-safari-for-ios-and-macos
function unlockAudioContext (audioCtx) {
if (audioCtx.state !== 'suspended') return
const b = document.body
const events = ['touchstart', 'touchend', 'mousedown', 'keydown']
events.forEach(e => b.addEventListener(e, unlock, false))
function unlock () { audioCtx.resume().then(clean) }
function clean () { events.forEach(e => b.removeEventListener(e, unlock)) }
}
}
},
Expand Down

0 comments on commit b32d519

Please sign in to comment.