Started using custom video controls

This commit is contained in:
2018-12-07 09:54:17 +09:00
parent da716fc3aa
commit 11865a6500
13 changed files with 126 additions and 54 deletions

View File

@ -2,7 +2,7 @@ import AnimeNotifier from "../AnimeNotifier"
// Play audio
export function playAudio(arn: AnimeNotifier, element: HTMLElement) {
arn.audioPlayer.play(element.dataset.soundtrackId, element.dataset.audioSrc)
arn.audioPlayer.play(element.dataset.mediaId, element.dataset.audioSrc)
}
// Pause audio
@ -45,7 +45,7 @@ export function playPauseAudio(arn: AnimeNotifier) {
export function toggleAudio(arn: AnimeNotifier, element: HTMLElement) {
// If we're clicking on the same track again, stop playing.
// Otherwise, start the track we clicked on.
if(arn.currentSoundTrackId && element.dataset.soundtrackId === arn.currentSoundTrackId) {
if(arn.currentMediaId && element.dataset.mediaId === arn.currentMediaId) {
stopAudio(arn)
} else {
playAudio(arn, element)

View File

@ -1,5 +1,5 @@
import AnimeNotifier from "../AnimeNotifier"
import Diff from "scripts/Diff";
import Diff from "scripts/Diff"
// Follow user
export async function followUser(arn: AnimeNotifier, element: HTMLElement) {

37
scripts/Actions/Video.ts Normal file
View File

@ -0,0 +1,37 @@
import AnimeNotifier from "../AnimeNotifier"
// Play video
export function playVideo(arn: AnimeNotifier, video: HTMLVideoElement) {
video.volume = arn.audioPlayer.volume
if(video.readyState >= 2) {
togglePlayVideo(video)
return
}
video.load()
video.addEventListener("loadeddata", () => {
togglePlayVideo(video)
})
}
function togglePlayVideo(video: HTMLVideoElement) {
if(video.paused) {
video.play()
} else {
video.pause()
}
}
// Toggle fullscreen
export function toggleFullscreen(arn: AnimeNotifier, button: HTMLElement) {
let elementId = button.dataset.id
let element = document.getElementById(elementId)
if(document.fullscreen) {
document.exitFullscreen()
} else {
element.requestFullscreen()
}
}

View File

@ -19,4 +19,5 @@ export * from "./Shop"
export * from "./SideBar"
export * from "./StatusMessage"
export * from "./Theme"
export * from "./Upload"
export * from "./Upload"
export * from "./Video"