Add fullscreen functionality to Thrimbletrimmer video player (#250)

* Add fullscreen functionality to Thrimbletrimmer video player

* Fix issue where clicking on fullscreen video pauses and unpauses instead of doing just one
pull/253/head
ElementalAlchemist 3 years ago committed by GitHub
parent d1ba4bc4eb
commit b1b8ef8973
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -67,6 +67,13 @@
<div>
<select id="video-controls-quality"></select>
</div>
<div>
<img
id="video-controls-fullscreen"
src="images/video-controls/fullscreen.png"
class="click"
/>
</div>
</div>
<progress id="video-controls-playback-position" value="0" class="click"></progress>
</div>

Binary file not shown.

After

Width:  |  Height:  |  Size: 633 B

@ -85,6 +85,13 @@
<div>
<select id="video-controls-quality"></select>
</div>
<div>
<img
id="video-controls-fullscreen"
src="images/video-controls/fullscreen.png"
class="click"
/>
</div>
</div>
<progress id="video-controls-playback-position" value="0" class="click"></progress>
</div>

@ -153,7 +153,11 @@ function setUpVideoControls() {
}
};
playPauseButton.addEventListener("click", togglePlayState);
videoElement.addEventListener("click", togglePlayState);
videoElement.addEventListener("click", (event) => {
if (!videoElement.controls) {
togglePlayState(event);
}
});
videoElement.addEventListener("play", (_event) => {
playPauseButton.src = "images/video-controls/pause.png";
@ -240,6 +244,22 @@ function setUpVideoControls() {
globalPlayer.currentLevel = +quality.value;
});
const fullscreen = document.getElementById("video-controls-fullscreen");
fullscreen.addEventListener("click", (_event) => {
if (document.fullscreenElement) {
document.exitFullscreen();
} else {
videoElement.requestFullscreen();
}
});
videoElement.addEventListener("fullscreenchange", (_event) => {
if (document.fullscreenElement) {
videoElement.controls = true;
} else {
videoElement.controls = false;
}
});
const playbackPosition = document.getElementById("video-controls-playback-position");
playbackPosition.max = videoElement.duration;
playbackPosition.value = videoElement.currentTime;

Loading…
Cancel
Save