/
🍿

Fullscreen video

javascripttypescript
ts
const openFullscreen = (elem: HTMLElement): Promise<any> => {
if (elem.requestFullscreen) {
return elem.requestFullscreen()
} else if (elem.mozRequestFullscreen) {
/* Firefox */
return elem.mozRequestFullscreen()
} else if (elem.webkitRequestFullscreen) {
/* Chrome, Safari and Opera */
return elem.webkitRequestFullscreen()
} else if (elem.msRequestFullscreen) {
/* IE/Edge */
return elem.msRequestFullscreen()
}
}
// Usage
openFullscreen(element).catch(error => {
Sentry.captureException(new Error(error))
Sentry.captureMessage(
`Error attempting to enable full-screen mode: ${error.message} (${error.name})`
)
})
Edit this page
Want to make your own site like this? Try gatsby-theme-code-notes by Zander Martineau.
Notes on code. My second brain, by Zander Martineau.