Skip to content

Conversation

@Juanmalopezg
Copy link
Contributor

Simple fullscreen support

I tagged the canvas's parent div with a ugly "video" id to handle UI controls in fullscreen. We should replace this once we have a custom web component for the entire element and use that instead.

fullscreen1.mp4

Copy link
Contributor

@christriants christriants left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is exciting to see! I left a few nitpicks / questions.

import { createEffect, createSignal, onCleanup } from "solid-js"

export const FullscreenButton = () => {
const [isActive, setIsActive] = createSignal(false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit for descriptiveness:

const [isFullscreen, setIsFullscreen]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done ✅

Comment on lines 18 to 23
const handleFullscreenChange = () => {
setIsActive(!!document.fullscreenElement)
}

document.addEventListener("fullscreenchange", handleFullscreenChange)
onCleanup(() => document.removeEventListener("fullscreenchange", handleFullscreenChange))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One day, it would be awesome if we could set up these events and get fullscreen from a shared store. Long-term, we could want to use this is in other areas.

Comment on lines 10 to 14
void videoElement?.requestFullscreen()
setIsActive(true)
} else {
void document.exitFullscreen()
setIsActive(false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we catch and warn if this fails?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done ✅

flex h-4 w-4 items-center justify-center rounded bg-transparent
p-4 text-white hover:bg-black/80 focus:outline-none
"
onClick={toggleFullscreen}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be cool to add a keyboard for toggling on/off this button, too! Maybe not in scope here, but f is generally the key used for going in and out of fullscreen when the player is focused.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done ✅

<>
<Fail error={error()} />
<div class="relative aspect-video w-full">
<div class="relative aspect-video w-full" id="video">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed the video gets stretched in fullscreen when using Chrome responsive tools. I guess it's probably because the canvas element isn't being re-sized correctly.

Screenshot 2024-12-13 at 8 18 09 PM

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes it doesn't preserve aspect ratio @christriants

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done ✅ Setting the object-contain CSS property on the canvas did the trick

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks awesome!

@christriants
Copy link
Contributor

Thanks for making those changes, even the nitpicks. Looks good to me.

@englishm englishm merged commit 4d0b29e into video-dev:main Jan 16, 2025
1 check passed
@Juanmalopezg Juanmalopezg deleted the fullscreen-feature branch January 16, 2025 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants