This tutorial shows how to create a custom video player.
As Wes challenged us, I have added fullscreen video functionality. The only issue to pay attention to was choosing the player element instead of video to keep the controls on screen.
Some concepts taught:
HTMLMediaElement APIforclick,play,pauseandtimeupdateeventsvolume,playbackRateandcurrentTimeproperties
Fullscreen APIfor therequestFullscreen()method
// fullscreen handler function
const handleFullscreen = () => {
if (!document.fullscreenElement) {
player.requestFullscreen()
.catch(err =>
alert(`Error attempting to enable full-screen mode: ${err.message} (${err.name})`)
)
} else {
document.exitFullscreen()
}
}