mirror of
https://github.com/koel/koel
synced 2024-12-29 22:13:06 +00:00
29 lines
670 B
TypeScript
29 lines
670 B
TypeScript
export const audioService = {
|
|
context: null as unknown as AudioContext,
|
|
source: null as unknown as MediaElementAudioSourceNode,
|
|
element: null as unknown as HTMLMediaElement,
|
|
|
|
init (element: HTMLMediaElement) {
|
|
const AudioContext = window.AudioContext ||
|
|
window.webkitAudioContext ||
|
|
window.mozAudioContext ||
|
|
window.oAudioContext ||
|
|
window.msAudioContext
|
|
|
|
this.context = new AudioContext()
|
|
this.source = this.context.createMediaElementSource(element)
|
|
this.element = element
|
|
},
|
|
|
|
getContext () {
|
|
return this.context
|
|
},
|
|
|
|
getSource () {
|
|
return this.source
|
|
},
|
|
|
|
getElement () {
|
|
return this.element
|
|
}
|
|
}
|