Added play in background button

This commit is contained in:
2018-03-11 03:00:06 +01:00
parent 8ac693734e
commit 8071e18c65
4 changed files with 21 additions and 0 deletions

13
scripts/Actions/Audio.ts Normal file
View File

@ -0,0 +1,13 @@
import { AnimeNotifier } from "../AnimeNotifier"
// Play audio file
export function playAudio(arn: AnimeNotifier, button: HTMLButtonElement) {
if(!arn.audio) {
arn.audio = document.createElement("audio") as HTMLAudioElement
let source = document.createElement("source") as HTMLSourceElement
source.src = button.dataset.src
arn.audio.appendChild(source)
}
arn.audio.play()
}