Exploring making my own picture-in-picture player using React
Haven’t we all gotten used to short-form videos and can no longer sit through anything more than 3 mins? Yeah me too.
Ever since I started using Arc Browser, I’ve been really enjoying the built-in picture-in-picture player.
Curious about how to make something similar, I thought I’d give it a shot.
Can’t trigger pip on scoll, only on click or manually selecting option by right clicking 🤷♂️
- trigger picture-in-picture when main placeholder is mostly out of view
- fade in animations
- close button to close picture-in-picture
- trigger picture-in-picture only when player is playing
-
Check if video is in view Intersection Observer API: browser API that allows you to monitor when an element enters or exits the viewport (the visible portion of a web page)
-
Position player at bottom right of screen when out of view Conditionally add
fixed
class to player when out of original placeholder view -
Animate player when transitioning between views Use keyframes and
animate
utility classes to animate player when transitioning between views -
Trigger picture-in-picture only when playing Conditionally trigger picture-in-picture only when player is playing by checking
mediapaused
attribute in theMediaController
-
Close button to close picture-in-picture Conditionally apply close button only when player is in floating state, handle state of player when close button is clicked