only get one click
This commit is contained in:
parent
0577adffb8
commit
e4877ab3a9
1 changed files with 44 additions and 38 deletions
|
@ -16,11 +16,13 @@ function setVideoSrc(video, src) {
|
|||
}
|
||||
video.src = src.replace('.webm', videoExtension)
|
||||
}
|
||||
var video
|
||||
|
||||
document.querySelector('a#play-fullscreen').addEventListener('click', event => {
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
var video = document.createElement('video')
|
||||
if (!video) {
|
||||
video = document.createElement('video')
|
||||
video.classList.add('player')
|
||||
setVideoSrc(video, 'https://pad.ma/' + film.id + '/480p.webm')
|
||||
video.controls = true
|
||||
|
@ -30,15 +32,16 @@ document.querySelector('a#play-fullscreen').addEventListener('click', event => {
|
|||
video.currentTime = continueTimecode
|
||||
}
|
||||
function enterFullscreen(event) {
|
||||
if (video.webkitEnterFullScreen) {
|
||||
video.webkitEnterFullScreen();
|
||||
video.removeEventListener('play', enterFullscreen);
|
||||
if (video.webkitRequestFullscreen) {
|
||||
video.requestFullscreen();
|
||||
} else {
|
||||
video.requestFullscreen().catch(err => {
|
||||
console.log(`Error attempting to enable full-screen mode: ${err.message} (${err.name})`);
|
||||
video.remove()
|
||||
video = null
|
||||
});
|
||||
}
|
||||
video.removeEventListener('play', enterFullscreen);
|
||||
setTimeout(() => {
|
||||
video.style.display = 'block'
|
||||
}, 150)
|
||||
|
@ -51,6 +54,7 @@ document.querySelector('a#play-fullscreen').addEventListener('click', event => {
|
|||
if (document.fullscreenElement) {
|
||||
document.exitFullscreen();
|
||||
}
|
||||
video = null
|
||||
}
|
||||
});
|
||||
video.addEventListener('pause', event => {
|
||||
|
@ -61,6 +65,8 @@ document.querySelector('a#play-fullscreen').addEventListener('click', event => {
|
|||
if (document.fullscreenElement) {
|
||||
document.exitFullscreen();
|
||||
}
|
||||
video = null
|
||||
});
|
||||
video.play()
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue