Layouts

DefaultLayout

The DefaultLayout component provides a ready-to-use, opinionated layout for the video player. It includes standard controls like a play/pause button, progress bar, time display, and settings menu, arranged in a familiar and intuitive way.

Usage

You can use DefaultLayout by passing it as a child to the VideoPlayer component.

VideoPlayer.tsx
import { VideoPlayer, DefaultLayout } from 'react-native-video-toolkit';

export const Player = () => {
  return (
    <VideoPlayer source={{ uri: 'https://example.com/video.mp4' }}>
      <DefaultLayout title="My Awesome Video" subtitle="An example of the DefaultLayout" />
    </VideoPlayer>
  );
};

Props

PropTypeDefaultDescription
titlestringThe main title of the video, displayed in the top-left corner.
titlePropsOmit<TitleProps, 'text'>Props to pass to the underlying Title component (e.g., for styling).
subtitlestringA subtitle or secondary text, displayed below the main title.
subtitlePropsOmit<SubtitleProps, 'text'>Props to pass to the underlying Subtitle component (e.g., for styling).
slotsobjectAn object that allows you to render custom components in predefined slots.
pinCaptionTrack(track: TextTrack) => booleanCaption tracks it returns true for are listed first in the settings menu's Captions list, above "Off", e.g. subtitles your app added.
scrimboolean | ColorValuetrueTints the video while the controls are visible, so they stand out on bright frames. true uses the theme's scrim color, a color sets it, and false turns it off. It's a VideoPlayer.Overlay behind the controls.

Slots

The slots prop allows you to inject your own components or elements into specific areas of the layout. This is useful for adding extra functionality or customizing the UI without having to rebuild the entire layout.

The slots prop provides a powerful way to extend the DefaultLayout while maintaining its overall structure.

Here are the available slots:

SlotDescription
beforeTitleRenders a component at the start of the top bar, before the title (e.g. a back button).
beforeSettingsButtonRenders a component before the settings button.
afterSettingsButtonRenders a component after the settings button.
beforeSubtitleToggleButtonRenders a component before the subtitle toggle button.
afterSubtitleToggleButtonRenders a component after the subtitle toggle button.
beforeProgressBarRenders a component above the progress bar.
afterProgressBarRenders a component below the progress bar.
beforeTimeDisplayRenders a component before the time display.
afterTimeDisplayRenders a component after the time display.
beforeMuteButtonRenders a component before the mute button.
afterMuteButtonRenders a component after the mute button.
beforePictureInPictureButtonRenders a component before the picture-in-picture button (shown when enablePictureInPicture is on).
afterPictureInPictureButtonRenders a component after the picture-in-picture button.
beforeFullscreenButtonRenders a component before the fullscreen button.
afterFullscreenButtonRenders a component after the fullscreen button.
beforeCenterPlayButtonRenders a component before the center play button.
afterCenterPlayButtonRenders a component after the center play button.
beforeMenuItemsRenders rows above Audio, Video, Captions and Rate in the settings menu, e.g. a Menu.Item that opens a view from menuViews.
afterMenuItemsRenders rows below Rate in the settings menu.
beforeCaptionTracksRenders rows above the tracks in the settings menu's Captions list, e.g. a Menu.Item that adds a subtitle file.
afterCaptionTracksRenders rows below the tracks in the settings menu's Captions list.
menuViewsExtra views for the settings menu: Menu.SubContents, opened by a <Menu.Item navigateTo="viewId"> in another slot or view. The header shows the view ID, capitalized.

Examples

Basic Usage

Here's a basic example of how to use the DefaultLayout with a title and subtitle.

-0s
+0s
My Awesome Video
An example of the DefaultLayout
0:00
/
0:00

Using Slots

This example demonstrates how to use the slots prop to add a custom "Like" button next to the fullscreen button.

-0s
+0s
My Awesome Video
0:00
/
0:00

On this page