Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to double-click to go fullscreen #1020

Open
rlaphoenix opened this issue Nov 7, 2024 · 0 comments
Open

Ability to double-click to go fullscreen #1020

rlaphoenix opened this issue Nov 7, 2024 · 0 comments

Comments

@rlaphoenix
Copy link

rlaphoenix commented Nov 7, 2024

This would be a very handy feature. I currently have it implemented as follows:

/* double-click-fullscreen.js */
import { useMediaDispatch, useMediaSelector, MediaActionTypes } from "media-chrome/react/media-store"


export default function useDoubleClickFullscreen() {
  /**
   * An onClick handler to enter/exit fullscreen on double-click.
   */
  const dispatch = useMediaDispatch()
  const isFullscreen = useMediaSelector(state => state.mediaIsFullscreen)
  return e => {
    if (e.detail === 2) {
      const type = isFullscreen
        ? MediaActionTypes.MEDIA_EXIT_FULLSCREEN_REQUEST
        : MediaActionTypes.MEDIA_ENTER_FULLSCREEN_REQUEST
      dispatch({ type })
    }
  }
}
/* where <video> is */
<video
  ref={el => {
    ref.current = el
    mediaRef(el)
  }}
  autoPlay
  crossOrigin="anonymous"
  slot="media"
  onClick={useDoubleClickFullscreen()}
  /*...*/

If your <video> already has an onClick handler, then just include it in that and rework the hook to be able to pass the event variable into it.

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

No branches or pull requests

1 participant