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

View File

@ -1,3 +1,4 @@
export * from "./Actions/Audio"
export * from "./Actions/AnimeList"
export * from "./Actions/Diff"
export * from "./Actions/Editor"

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()
}

View File

@ -32,6 +32,7 @@ export class AnimeNotifier {
mainPageLoaded: boolean
isLoading: boolean
lastReloadContentPath: string
audio: HTMLAudioElement
elementFound: MutationQueue
elementNotFound: MutationQueue