2021-10-22 09:56:05 +00:00
|
|
|
var videoExtension
|
2021-10-24 09:01:55 +00:00
|
|
|
var continueTimecode
|
2021-10-22 09:56:05 +00:00
|
|
|
|
2021-10-22 08:21:43 +00:00
|
|
|
function setVideoSrc(video, src) {
|
|
|
|
var ext
|
|
|
|
if (!videoExtension) {
|
|
|
|
[
|
|
|
|
['video/mp4; codecs="avc1.42E01E, mp4a.40.2"', '.mp4'],
|
|
|
|
['video/webm; codecs="vp8, vorbis"', '.webm'],
|
|
|
|
].forEach(opt => {
|
|
|
|
if (videoExtension) { return }
|
|
|
|
if (video.canPlayType(opt[0]).replace('no', '')) {
|
|
|
|
videoExtension = opt[1]
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
video.src = src.replace('.webm', videoExtension)
|
|
|
|
}
|
2021-10-25 08:23:06 +00:00
|
|
|
var video
|
2021-10-22 08:21:43 +00:00
|
|
|
|
2021-10-11 14:38:22 +00:00
|
|
|
document.querySelector('a#play-fullscreen').addEventListener('click', event => {
|
2021-10-22 09:56:05 +00:00
|
|
|
event.preventDefault()
|
|
|
|
event.stopPropagation()
|
2021-10-26 13:04:08 +00:00
|
|
|
|
|
|
|
// For some unknown reason, we need to set the timeline-video to display:none
|
|
|
|
// when playing the film in fullscreen, otherwise the fullscreen video
|
2021-10-27 08:54:56 +00:00
|
|
|
// shows a black screen on Safari (15.0.2 on an m1 laptop)
|
2021-10-26 13:04:08 +00:00
|
|
|
document.getElementById('timeline-video').style.display = 'none'
|
2021-10-25 08:23:06 +00:00
|
|
|
if (!video) {
|
|
|
|
video = document.createElement('video')
|
|
|
|
video.classList.add('player')
|
2021-10-25 08:29:40 +00:00
|
|
|
video.classList.add('fullscreen')
|
2021-10-27 15:19:55 +00:00
|
|
|
//setVideoSrc(video, 'https://pad.ma/' + film.id + '/480p.webm')
|
2021-10-28 15:37:48 +00:00
|
|
|
video.src = `${film.prefix}stream/${film.id}.mp4`
|
2021-10-25 08:23:06 +00:00
|
|
|
video.controls = true
|
2021-10-27 17:15:56 +00:00
|
|
|
video.controlsList = 'nodownload'
|
2021-10-25 08:23:06 +00:00
|
|
|
document.querySelector('main').appendChild(video)
|
|
|
|
video.style.display = 'none'
|
|
|
|
if (continueTimecode) {
|
|
|
|
video.currentTime = continueTimecode
|
2021-10-25 07:53:39 +00:00
|
|
|
}
|
2021-10-26 13:04:08 +00:00
|
|
|
|
|
|
|
function onFullscreenChange (event) {
|
|
|
|
if (document.fullscreenElement === null || document.webkitFullscreenElement === null) {
|
2021-10-25 08:23:06 +00:00
|
|
|
continueTimecode = video.currentTime
|
|
|
|
video.remove()
|
2021-10-26 13:04:08 +00:00
|
|
|
document.getElementById('timeline-video').style.display = 'block'
|
2021-10-27 08:54:56 +00:00
|
|
|
if (document.fullscreenElement) {
|
|
|
|
document.exitFullscreen()
|
|
|
|
}
|
|
|
|
if (document.webkitFullscreenElement) {
|
|
|
|
document.webkitExitFullscreen()
|
2021-10-25 08:23:06 +00:00
|
|
|
}
|
|
|
|
video = null
|
|
|
|
}
|
2021-10-26 13:04:08 +00:00
|
|
|
}
|
|
|
|
video.addEventListener('webkitfullscreenchange', onFullscreenChange)
|
|
|
|
video.addEventListener('fullscreenchange', onFullscreenChange)
|
2021-10-25 08:23:06 +00:00
|
|
|
video.addEventListener('pause', event => {
|
|
|
|
})
|
|
|
|
video.addEventListener('ended', event => {
|
|
|
|
continueTimecode = 0
|
2021-10-11 14:38:22 +00:00
|
|
|
video.remove()
|
2021-10-27 08:54:56 +00:00
|
|
|
document.getElementById('timeline-video').style.display = 'block'
|
|
|
|
if (document.webkitFullscreenElement) {
|
|
|
|
document.webkitExitFullscreen()
|
|
|
|
}
|
2021-10-11 14:38:22 +00:00
|
|
|
if (document.fullscreenElement) {
|
|
|
|
document.exitFullscreen();
|
|
|
|
}
|
2021-10-25 08:23:06 +00:00
|
|
|
video = null
|
2021-10-27 08:54:56 +00:00
|
|
|
})
|
2021-10-25 08:23:06 +00:00
|
|
|
video.play()
|
2021-10-26 13:04:08 +00:00
|
|
|
video.style.display = 'block'
|
|
|
|
if (video.webkitRequestFullscreen) {
|
2021-10-28 07:01:42 +00:00
|
|
|
video.webkitRequestFullscreen({navigationUI: 'hide'})
|
2021-10-26 13:04:08 +00:00
|
|
|
} else {
|
2021-10-28 07:01:42 +00:00
|
|
|
video.requestFullscreen({navigationUI: 'hide'}).catch(err => {
|
2021-10-26 13:04:08 +00:00
|
|
|
console.log(`Error attempting to enable full-screen mode: ${err.message} (${err.name})`);
|
|
|
|
video.remove()
|
|
|
|
video = null
|
|
|
|
});
|
2021-10-27 15:19:55 +00:00
|
|
|
}
|
2021-10-25 08:23:06 +00:00
|
|
|
}
|
2021-10-11 14:38:22 +00:00
|
|
|
})
|