Skip to main content
Version: v7 Beta

Refs and Imperative Methods

You can obtain a ref to the VideoView component to call imperative methods:

const videoViewRef = React.useRef<VideoViewRef>(null);

// ...

<VideoView ref={videoViewRef} player={player} />

// Later, you can call methods like:
videoViewRef.current?.enterFullscreen();

Available methods on the VideoViewRef:

MethodTypeDescription
enterFullscreen()() => voidProgrammatically requests the video view to enter fullscreen mode.
exitFullscreen()() => voidProgrammatically requests the video view to exit fullscreen mode.
enterPictureInPicture()() => voidProgrammatically requests the video view to enter picture-in-picture mode.
exitPictureInPicture()() => voidProgrammatically requests the video view to exit picture-in-picture mode.
canEnterPictureInPicture()() => booleanChecks if picture-in-picture mode is currently available and supported. Returns true if PiP can be entered, false otherwise.