40 lines
1.1 KiB
TypeScript
Raw Normal View History

2018-12-07 00:54:17 +00:00
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
}
2018-12-07 20:19:50 +00:00
video.addEventListener("canplay", () => {
2018-12-07 00:54:17 +00:00
togglePlayVideo(video)
})
2018-12-07 19:40:27 +00:00
video.load()
2018-12-07 00:54:17 +00:00
}
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)
2018-12-07 21:35:42 +00:00
let requestFullscreen = element.requestFullscreen || element["mozRequestFullScreen"] || element["webkitRequestFullScreen"] || element["msRequestFullscreen"]
let exitFullscreen = document.exitFullscreen || document["mozCancelFullScreen"] || document["webkitExitFullscreen"] || document["msExitFullscreen"]
let fullscreen = document.fullscreen || document["webkitIsFullScreen"] || document["mozFullScreen"]
2018-12-07 00:54:17 +00:00
if(fullscreen) {
2018-12-07 21:35:42 +00:00
exitFullscreen.call(document)
2018-12-07 00:54:17 +00:00
} else {
2018-12-07 21:35:42 +00:00
requestFullscreen.call(element)
2018-12-07 00:54:17 +00:00
}
}