React Native · Components
VideoPlayer
Video player (same API as the web VideoPlayer).
Live example
The preview runs in the browser with the web component; the native component takes the same props and looks the same on iOS and Android.
Preview
Code
Events
- Events appear here when you interact with the preview.
Reels style: muted, looping, pauses on tap
Import
VideoPlayer
componentVideo player (same API as the web VideoPlayer). The picture is drawn by the library's own native view (Android MediaPlayer, iOS AVPlayer; no extra library); the controls are drawn the same on both platforms.
- Controls: play/pause, seek bar (draggable), duration, captions, speed and quality menus, mute, fullscreen. They hide a few seconds after playback starts; a tap shows them.
- Double tap: the right half skips forward, the left half back.
- `controls="minimal"`: Reels/Shorts style; tap to pause/play.
- Cover: without
postera frame is extracted from the video. - Fullscreen: covers the whole screen above the app; the Android back button exits.
- Pauses when the app goes to the background.
Importing @yasinsensoy/native/video-player adds the video native module to the build.
Examples
VideoFrameImage
componentShows a frame of a video without a cover image as an image (fills the container). Empty until the frame is extracted; fades in when it is.
Examples
cachedVideoFrame
functionThe extracted frame if cached; otherwise undefined.
extractVideoFrame
functionExtracts a frame of the video (see the top of the file). A single job runs per address; the result is cached. When signal is aborted and nobody else is waiting, the job leaves the queue. null if the video cannot be opened or the video module is not in the build.
Examples
useVideoFrame
functionFrame of a video without a cover image. No job starts while enabled is false; the pending job is cancelled when the component unmounts (or the address changes).
VideoFrame
interfaceResult of extractVideoFrame.
| Name | Type | Description |
|---|---|---|
url | string | Image URL of the frame (file://). |
width | number | Width of the frame (px). The ratio is the video's ratio. |
height | number | Height of the frame (px). |
VideoFrameImageProps
interfaceVideoFrameImage props.
| Name | Type | Default | Description |
|---|---|---|---|
src | string | Video address. | |
fit? | "cover" | "contain" | "cover" | Fit in the box. |
onFrame? | (frame: VideoFrame) => void | When the frame is extracted (to measure its ratio). | |
style? | StyleProp<ImageStyle> | Image style. Fills the container if omitted. |
VideoSource
interfaceA video source for VideoPlayer.
| Name | Type | Description |
|---|---|---|
src | string | Video address. |
type? | string | MIME type (for source lists shared with web; not used on native). |
label? | string | Quality name ("1080p", "720p"). If any source is named, a quality menu appears in the settings; switching keeps the position and playback state. The first source is the default. |
VideoTrack
interfaceCaption file (WebVTT) for VideoPlayer.
| Name | Type | Default | Description |
|---|---|---|---|
src | string | URL of the .vtt file. | |
srcLang | string | Language code ("tr", "en"). | |
label | string | Name shown in the menu ("English"). | |
kind? | "subtitles" | "captions" | "subtitles" | Kind. |
default? | boolean | Initially on. |
VideoPlayerHandle
interfaceFor controlling the player from code (ref).
| Name | Type | Description |
|---|---|---|
play | (): void | Plays. |
pause | (): void | Stops. |
toggle | (): void | Plays or pauses. |
seek | (time: number): void | Seeks to a position (seconds). |
currentTime | number | Current position (seconds). |
duration | number | Duration (seconds; 0 if unknown). |
enterFullscreen | (): void | Enters fullscreen. |
exitFullscreen | (): void | Exits fullscreen. |
VideoPlayerProps
interfaceVideoPlayer props.
| Name | Type | Default | Description |
|---|---|---|---|
src | string | readonly VideoSource[] | Video URL or a source list. See VideoSource. | |
poster? | string | Cover image shown before the video starts. | |
autoPoster? | boolean | true | If poster is omitted, a frame is extracted from the video as the cover (on the native side, cached). |
title? | string | Title. Shown at the top in fullscreen. | |
tracks? | readonly VideoTrack[] | Captions (WebVTT). See VideoTrack. | |
autoPlay? | boolean | Play automatically when opened. | |
muted? | boolean | Starts muted. | |
loop? | boolean | Starts over when finished. | |
controls? | boolean | "minimal" | true | Controls: true the full bar; "minimal" Reels/Shorts style (tap to pause/play, a thin seek bar and a mute button at the bottom); false none. |
aspectRatio? | number | "auto" | "fill" | 16 / 9 | Aspect ratio. A number (16 / 9), "auto" (the video's own ratio) or "fill" (fills the container; you give the size). |
fit? | "contain" | "cover" | "contain" | How the picture fits the box. |
playbackRates? | readonly number[] | [0.5, 0.75, 1, 1.25, 1.5, 2] | Speeds in the settings. |
seekStep? | number | 5 | Seconds skipped on double tap (twice that is skipped). |
startTime? | number | Start position (seconds). | |
rememberVolume? | boolean | true | Remember the mute preference while the app stays open; players opened later start with the last choice. On phones volume is on the hardware buttons; there is no volume bar. |
headers? | Record<string, string> | Request headers (Authorization for protected videos). | |
label? | string | title | Screen reader name. |
onPlay? | () => void | When playback starts. | |
onPause? | () => void | On pause. | |
onEnded? | () => void | On end. | |
onTimeUpdate? | (time: number, duration: number) => void | When the position changes (several times a second), with the current position and duration. | |
onError? | () => void | When the video cannot be opened. | |
onFullscreenChange? | (fullscreen: boolean) => void | When entering and exiting fullscreen. | |
style? | StyleProp<ViewStyle> | Style of the box. | |
ref? | Ref<VideoPlayerHandle> | For controlling the player from code. See VideoPlayerHandle. | |
testID? | string | Test id. |