Image, ImageShader, and Atlas components.
Requirements
- React Native Reanimated version 3 or higher
- Android API level 26 or higher
- Web Fully supported
useVideo Hook
TheuseVideo hook loads video files and provides the current frame as a shared value.
Basic Example
Returned Values
TheuseVideo hook returns an object with:
| Property | Type | Description |
|---|---|---|
| currentFrame | SharedValue<SkImage | null> | Current video frame or null if not loaded |
| currentTime | SharedValue<number> | Current playback position in milliseconds |
| duration | number | Total video duration in milliseconds |
| framerate | number | Video frame rate (frames per second) |
| rotation | 0 | 90 | 180 | 270 | Video rotation in degrees |
| size | { width: number, height: number } | Video dimensions |
Using Returned Values
Playback Options
Control video playback with options:| Option | Type | Description |
|---|---|---|
| paused | SharedValue<boolean> | Controls pause state |
| looping | SharedValue<boolean> | Enables looping |
| seek | SharedValue<number | null> | Seek to specific time in milliseconds |
| volume | SharedValue<number> | Volume level (0-1, where 0 is muted) |
Pause and Play
Looping Video
Seeking
Volume Control
Loading Videos
From Network
From Local File
From Assets with Expo
Handling Rotation
Videos can have rotation metadata. Use thefitbox function to handle rotation:
Using with Shaders
Video frames can be used as shader inputs:Complete Player Example
Performance Tips
- Use appropriate video resolution for your use case
- Consider using lower frame rates for better performance
- Limit the number of simultaneous videos
- Pause videos when not visible
- Use hardware acceleration when available
Video Encoding
To encode videos from Skia images:- Use ffmpeg for command-line encoding
- Check out react-native-skia-video for video encoding support
Supported Formats
Supported formats vary by platform: iOS:- MP4
- MOV
- M4V
- MP4
- 3GP
- WebM
- MKV
- MP4
- WebM
- OGG
Troubleshooting
Video Not Playing
- Check that the video URL is accessible
- Verify the video format is supported
- Ensure Reanimated is properly installed
- Check Android API level (26+)
Poor Performance
- Reduce video resolution
- Lower frame rate
- Use hardware-accelerated formats
- Limit number of simultaneous videos
Audio Issues
- Check volume settings
- Verify audio is present in source file
- Test with different video files
See Also
- Images Overview - Loading static images
- Animated Images - GIF and WebP animations
- Image Shaders - Using images as shaders