Added play in background button

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

View File

@ -14,6 +14,12 @@ component Track(track *arn.SoundTrack, user *arn.User)
.sound-track-media.video-container .sound-track-media.video-container
iframe.lazy.video(data-src=media.EmbedLink(), allowfullscreen="allowfullscreen") iframe.lazy.video(data-src=media.EmbedLink(), allowfullscreen="allowfullscreen")
if user != nil && media.Service == "Youtube" && (user.Role == "admin" || user.Role == "editor") && track.File != ""
.buttons
button.action(data-action="playAudio", data-trigger="click", data-src="/audio/" + track.File)
Icon("play")
span Play in background
.widget.mountable .widget.mountable
h3.widget-title Anime h3.widget-title Anime

View File

@ -1,3 +1,4 @@
export * from "./Actions/Audio"
export * from "./Actions/AnimeList" export * from "./Actions/AnimeList"
export * from "./Actions/Diff" export * from "./Actions/Diff"
export * from "./Actions/Editor" 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 mainPageLoaded: boolean
isLoading: boolean isLoading: boolean
lastReloadContentPath: string lastReloadContentPath: string
audio: HTMLAudioElement
elementFound: MutationQueue elementFound: MutationQueue
elementNotFound: MutationQueue elementNotFound: MutationQueue