diff --git a/app/static/js/film.js b/app/static/js/film.js index 027c175..cf4415e 100644 --- a/app/static/js/film.js +++ b/app/static/js/film.js @@ -21,6 +21,11 @@ var video document.querySelector('a#play-fullscreen').addEventListener('click', event => { event.preventDefault() event.stopPropagation() + + // For some unknown reason, we need to set the timeline-video to display:none + // when playing the film in fullscreen, otherwise the fullscreen video + // shows a black screen on Safari (15.0.2 on a laptop) + document.getElementById('timeline-video').style.display = 'none' if (!video) { video = document.createElement('video') video.classList.add('player') @@ -32,32 +37,29 @@ document.querySelector('a#play-fullscreen').addEventListener('click', event => { if (continueTimecode) { video.currentTime = continueTimecode } - function enterFullscreen(event) { - video.removeEventListener('play', enterFullscreen); - if (video.webkitRequestFullscreen) { - video.webkitRequestFullscreen(); - } else { - video.requestFullscreen().catch(err => { - console.log(`Error attempting to enable full-screen mode: ${err.message} (${err.name})`); - video.remove() - video = null - }); - } - setTimeout(() => { - video.style.display = 'block' - }, 150) - } - video.addEventListener('play', enterFullscreen); - video.addEventListener('fullscreenchange', event => { - if (document.fullscreenElement === null) { + // function enterFullscreen(event) { + // console.log('enter fullscreen called') + // video.removeEventListener('play', enterFullscreen) + + // // setTimeout(() => { + // // video.style.display = 'block' + // // }, 150) + // } + // video.addEventListener('play', enterFullscreen); + + function onFullscreenChange (event) { + if (document.fullscreenElement === null || document.webkitFullscreenElement === null) { continueTimecode = video.currentTime video.remove() - if (document.fullscreenElement) { + document.getElementById('timeline-video').style.display = 'block' + if (document.fullscreenElement || document.webkitFullscreenElement) { document.exitFullscreen(); } video = null } - }); + } + video.addEventListener('webkitfullscreenchange', onFullscreenChange) + video.addEventListener('fullscreenchange', onFullscreenChange) video.addEventListener('pause', event => { }) video.addEventListener('ended', event => { @@ -69,5 +71,17 @@ document.querySelector('a#play-fullscreen').addEventListener('click', event => { video = null }); video.play() + video.style.display = 'block' + if (video.webkitRequestFullscreen) { + console.log('webkitRequestFullscreen exists') + video.webkitRequestFullscreen() + } else { + video.requestFullscreen().catch(err => { + console.log(`Error attempting to enable full-screen mode: ${err.message} (${err.name})`); + video.remove() + video = null + }); + } + } }) diff --git a/app/templates/film.html b/app/templates/film.html index 2896ab5..315e5cf 100755 --- a/app/templates/film.html +++ b/app/templates/film.html @@ -32,8 +32,18 @@ body { -
{{ film.data.summary|safe }}