attempt fix subs fullscreen
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
const seekReducer = useReducer(reducers.seek);
|
const seekReducer = useReducer(reducers.seek);
|
||||||
|
|
||||||
let videoElement: HTMLVideoElement | undefined = $state();
|
let videoElement: HTMLVideoElement | undefined = $state();
|
||||||
|
let containerElement: HTMLDivElement | undefined = $state();
|
||||||
let newUrl = $state("");
|
let newUrl = $state("");
|
||||||
let newSubtitleUrl = $state("");
|
let newSubtitleUrl = $state("");
|
||||||
|
|
||||||
@@ -141,6 +142,14 @@
|
|||||||
setSubtitleUrlReducer({ url: newSubtitleUrl });
|
setSubtitleUrlReducer({ url: newSubtitleUrl });
|
||||||
newSubtitleUrl = "";
|
newSubtitleUrl = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toggleFullscreen() {
|
||||||
|
if (!document.fullscreenElement) {
|
||||||
|
containerElement?.requestFullscreen().catch(console.error);
|
||||||
|
} else {
|
||||||
|
document.exitFullscreen();
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="p-4">
|
<div class="p-4">
|
||||||
@@ -175,22 +184,60 @@
|
|||||||
</form>
|
</form>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
<div
|
||||||
|
bind:this={containerElement}
|
||||||
|
class="fullscreen-container relative w-full max-w-2xl bg-black"
|
||||||
|
>
|
||||||
<!-- svelte-ignore a11y_media_has_caption -->
|
<!-- svelte-ignore a11y_media_has_caption -->
|
||||||
<video
|
<video
|
||||||
bind:this={videoElement}
|
bind:this={videoElement}
|
||||||
muted
|
muted
|
||||||
controls
|
controls
|
||||||
|
controlslist="nofullscreen"
|
||||||
crossorigin="anonymous"
|
crossorigin="anonymous"
|
||||||
onplay={handlePlay}
|
onplay={handlePlay}
|
||||||
onpause={handlePause}
|
onpause={handlePause}
|
||||||
onseeked={handleSeeked}
|
onseeked={handleSeeked}
|
||||||
ontimeupdate={handleTimeUpdate}
|
ontimeupdate={handleTimeUpdate}
|
||||||
class="w-full max-w-2xl bg-black"
|
ondblclick={toggleFullscreen}
|
||||||
|
class="h-full w-full"
|
||||||
>
|
>
|
||||||
{#if videoState?.subtitleUrl && !videoState.subtitleUrl.endsWith(".ass")}
|
{#if videoState?.subtitleUrl && !videoState.subtitleUrl.endsWith(".ass")}
|
||||||
<track src={videoState.subtitleUrl} kind="subtitles" srclang="en" label="English" default />
|
<track
|
||||||
|
src={videoState.subtitleUrl}
|
||||||
|
kind="subtitles"
|
||||||
|
srclang="en"
|
||||||
|
label="English"
|
||||||
|
default
|
||||||
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
Your browser does not support the video tag.
|
Your browser does not support the video tag.
|
||||||
</video>
|
</video>
|
||||||
|
<button
|
||||||
|
onclick={toggleFullscreen}
|
||||||
|
class="absolute top-2 right-2 z-50 rounded bg-black/70 px-2 py-1 text-xs text-white opacity-50 transition-opacity hover:opacity-100"
|
||||||
|
>
|
||||||
|
Fullscreen
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
:global(.JASSUB) {
|
||||||
|
width: 100% !important;
|
||||||
|
height: 100% !important;
|
||||||
|
}
|
||||||
|
:global(.fullscreen-container:fullscreen) {
|
||||||
|
max-width: none !important;
|
||||||
|
width: 100vw !important;
|
||||||
|
height: 100vh !important;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
:global(.fullscreen-container:fullscreen video) {
|
||||||
|
width: 100% !important;
|
||||||
|
height: 100% !important;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user