mirror of
https://github.com/owntone/owntone-server.git
synced 2025-07-16 04:11:55 -04:00
[web] Simplify audio library
This commit is contained in:
parent
a4086ee314
commit
b52fd89474
@ -1,16 +1,13 @@
|
||||
export default {
|
||||
audio: null,
|
||||
context: null,
|
||||
source: null,
|
||||
play(url) {
|
||||
this.stop()
|
||||
this.audio = new Audio(`${String(url || '')}?x=${Date.now()}`)
|
||||
this.audio.crossOrigin = 'anonymous'
|
||||
this.context = new (window.AudioContext || window.webkitAudioContext)()
|
||||
this.source = this.context.createMediaElementSource(this.audio)
|
||||
this.source.connect(this.context.destination)
|
||||
const context = new (window.AudioContext || window.webkitAudioContext)()
|
||||
const source = context.createMediaElementSource(this.audio)
|
||||
source.connect(context.destination)
|
||||
this.audio.addEventListener('canplay', () => {
|
||||
this.context.resume().then(() => {
|
||||
context.resume().then(() => {
|
||||
this.audio.play()
|
||||
})
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user