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)
|
video.src = src.replace('.webm', videoExtension)
|
||||||
}
|
}
|
||||||
|
var video
|
||||||
|
|
||||||
document.querySelector('a#play-fullscreen').addEventListener('click', event => {
|
document.querySelector('a#play-fullscreen').addEventListener('click', event => {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
event.stopPropagation()
|
event.stopPropagation()
|
||||||
var video = document.createElement('video')
|
if (!video) {
|
||||||
|
video = document.createElement('video')
|
||||||
video.classList.add('player')
|
video.classList.add('player')
|
||||||
setVideoSrc(video, 'https://pad.ma/' + film.id + '/480p.webm')
|
setVideoSrc(video, 'https://pad.ma/' + film.id + '/480p.webm')
|
||||||
video.controls = true
|
video.controls = true
|
||||||
|
@ -30,15 +32,16 @@ document.querySelector('a#play-fullscreen').addEventListener('click', event => {
|
||||||
video.currentTime = continueTimecode
|
video.currentTime = continueTimecode
|
||||||
}
|
}
|
||||||
function enterFullscreen(event) {
|
function enterFullscreen(event) {
|
||||||
if (video.webkitEnterFullScreen) {
|
video.removeEventListener('play', enterFullscreen);
|
||||||
video.webkitEnterFullScreen();
|
if (video.webkitRequestFullscreen) {
|
||||||
|
video.requestFullscreen();
|
||||||
} else {
|
} else {
|
||||||
video.requestFullscreen().catch(err => {
|
video.requestFullscreen().catch(err => {
|
||||||
console.log(`Error attempting to enable full-screen mode: ${err.message} (${err.name})`);
|
console.log(`Error attempting to enable full-screen mode: ${err.message} (${err.name})`);
|
||||||
video.remove()
|
video.remove()
|
||||||
|
video = null
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
video.removeEventListener('play', enterFullscreen);
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
video.style.display = 'block'
|
video.style.display = 'block'
|
||||||
}, 150)
|
}, 150)
|
||||||
|
@ -51,6 +54,7 @@ document.querySelector('a#play-fullscreen').addEventListener('click', event => {
|
||||||
if (document.fullscreenElement) {
|
if (document.fullscreenElement) {
|
||||||
document.exitFullscreen();
|
document.exitFullscreen();
|
||||||
}
|
}
|
||||||
|
video = null
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
video.addEventListener('pause', event => {
|
video.addEventListener('pause', event => {
|
||||||
|
@ -61,6 +65,8 @@ document.querySelector('a#play-fullscreen').addEventListener('click', event => {
|
||||||
if (document.fullscreenElement) {
|
if (document.fullscreenElement) {
|
||||||
document.exitFullscreen();
|
document.exitFullscreen();
|
||||||
}
|
}
|
||||||
|
video = null
|
||||||
});
|
});
|
||||||
video.play()
|
video.play()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue