Expo Video (expo-av)
A library that provides an API to implement video playback and recording in apps.
Deprecated: TheVideocomponent fromexpo-av, which is documented on this page, has now been deprecated and replaced by an improved version inexpo-video. Learn aboutexpo-video.
The Video component from expo-av displays a video inline with the other UI elements in your app.
Much of Video and Audio have common APIs that are documented in AV documentation. This page covers video-specific props and APIs. We encourage you to skim through this document to get basic video working, and then move on to AV documentation for more advanced functionality. The audio experience of video (such as whether to interrupt music already playing in another app, or whether to play sound while the phone is on silent mode) can be customized using the Audio API.
Installation
- npx expo install expo-avIf you are installing this in an existing React Native app, make sure to install expo in your project.
Usage
Here's a simple example of a video with a play/pause button.
import { useState, useRef } from 'react'; import { View, StyleSheet, Button } from 'react-native'; import { Video, ResizeMode } from 'expo-av'; export default function App() { const video = useRef(null); const [status, setStatus] = useState({}); return ( <View style={styles.container}> <Video ref={video} style={styles.video} source={{ uri: 'https://d23dyxeqlo5psv.cloudfront.net/big_buck_bunny.mp4', }} useNativeControls resizeMode={ResizeMode.CONTAIN} isLooping onPlaybackStatusUpdate={status => setStatus(() => status)} /> <View style={styles.buttons}> <Button title={status.isPlaying ? 'Pause' : 'Play'} onPress={() => status.isPlaying ? video.current.pauseAsync() : video.current.playAsync() } /> </View> </View> ); } %%placeholder-start%%const styles = StyleSheet.create({ ... }); %%placeholder-end%%const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', backgroundColor: '#ecf0f1', }, video: { alignSelf: 'center', width: 320, height: 200, }, buttons: { flexDirection: 'row', justifyContent: 'center', alignItems: 'center', }, });
For more advanced examples, check out the Playlist example, and the custom VideoPlayer controls component that wraps <Video>, adds custom controls and use the <Video> API extensively. The VideoPlayer controls is used in this app.
API
import { Video } from 'expo-av';
No API data file found, sorry!
Unified API
The rest of the API on the Video component ref is the same as the API for Audio.Sound - see the AV documentation for further information.