player: fullscreen button (scales with the window)
'⛶ full' in the controls: native requestFullscreen on the video (it fills the viewport and rescales on window resize for free), with the iOS webkitEnterFullscreen fallback where the Fullscreen API doesn't exist. Click again to exit. Live browser test: enter + exit via the button.
This commit is contained in:
1 parent
379f591180
commit
cea04a20f6
2 files changed
+44
No files matched your search
@@ -446,6 +446,22 @@ async function showAnime(slug_id, opts = {}) {
|
||||
anB.classList.toggle("on", autoNext);
|
||||
};
|
||||
const ctl = [langBtn, spd, prevB, nextB, fillB, jump, anB];
|
||||
const fsB = el("button", "tiny", "\u26f6 full");
|
||||
fsB.title = "fullscreen";
|
||||
fsB.onclick = () => {
|
||||
const v = document.querySelector("#player video");
|
||||
if (!v) return;
|
||||
if (document.fullscreenElement || document.webkitFullscreenElement) {
|
||||
(document.exitFullscreen || document.webkitExitFullscreen).call(document);
|
||||
return;
|
||||
}
|
||||
// native Fullscreen API: the video fills the window (and scales with it);
|
||||
// iOS Safari has no element fullscreen, so fall back to its in-player one
|
||||
if (v.requestFullscreen) v.requestFullscreen();
|
||||
else if (v.webkitEnterFullscreen) v.webkitEnterFullscreen();
|
||||
else if (v.webkitRequestFullscreen) v.webkitRequestFullscreen();
|
||||
};
|
||||
ctl.push(fsB);
|
||||
if (document.pictureInPictureEnabled) {
|
||||
const pipB = el("button", "tiny", "\u29c9 PiP");
|
||||
pipB.title = "picture-in-picture";
|
||||
|
||||
Reference in new issue
Block a user