Started using custom video controls
This commit is contained in:
@ -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)
|
||||
|
@ -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
37
scripts/Actions/Video.ts
Normal 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()
|
||||
}
|
||||
}
|
@ -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"
|
Reference in New Issue
Block a user