Merge pull request 'remember video last time-code and set to that when user clicks play again on film page' (#17) from remember-video-tc into main

Reviewed-on: 0x2620/aab21#17
This commit is contained in:
j 2021-10-24 10:41:34 +00:00
commit 09d3dcc43d

View file

@ -1,4 +1,5 @@
var videoExtension
var continueTimecode
function setVideoSrc(video, src) {
var ext
@ -25,6 +26,9 @@ document.querySelector('a#play-fullscreen').addEventListener('click', event => {
video.controls = true
document.querySelector('main').appendChild(video)
video.style.display = 'none'
if (continueTimecode) {
video.currentTime = continueTimecode
}
function enterFullscreen(event) {
video.requestFullscreen().catch(err => {
console.log(`Error attempting to enable full-screen mode: ${err.message} (${err.name})`);
@ -38,6 +42,7 @@ document.querySelector('a#play-fullscreen').addEventListener('click', event => {
video.addEventListener('play', enterFullscreen);
video.addEventListener('fullscreenchange', event => {
if (!document.fullscreen) {
continueTimecode = video.currentTime
video.remove()
if (document.fullscreenElement) {
document.exitFullscreen();
@ -47,6 +52,7 @@ document.querySelector('a#play-fullscreen').addEventListener('click', event => {
video.addEventListener('pause', event => {
})
video.addEventListener('ended', event => {
continueTimecode = 0
video.remove()
if (document.fullscreenElement) {
document.exitFullscreen();