Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
238 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
--- | ||
title: Video (expo-av) | ||
description: A library that provides an API to implement video playback and recording in apps. | ||
sourceCodeUrl: 'https://github.com/expo/expo/tree/main/packages/expo-av' | ||
packageName: 'expo-av' | ||
iconUrl: '/static/images/packages/expo-av.png' | ||
platforms: ['android', 'ios', 'web'] | ||
--- | ||
|
||
import APISection from '~/components/plugins/APISection'; | ||
import { APIInstallSection } from '~/components/plugins/InstallSection'; | ||
import { SnackInline } from '~/ui/components/Snippet'; | ||
|
||
> **info** The `Video` component from expo-av, which is documented on this page, will be replaced by an improved version in expo-video in an upcoming release (when the new library is stable). [Learn about expo-video](video.mdx) | ||
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](av.mdx). 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](av.mdx) 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](audio.mdx). | ||
|
||
## Installation | ||
|
||
<APIInstallSection /> | ||
|
||
## Usage | ||
|
||
Here's a simple example of a video with a play/pause button. | ||
|
||
<SnackInline label='Video' dependencies={['expo-av', 'expo-asset']}> | ||
|
||
```jsx | ||
import * as React from 'react'; | ||
import { View, StyleSheet, Button } from 'react-native'; | ||
import { Video, ResizeMode } from 'expo-av'; | ||
|
||
export default function App() { | ||
const video = React.useRef(null); | ||
const [status, setStatus] = React.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> | ||
); | ||
} | ||
|
||
/* @hide const styles = StyleSheet.create({ ... }); */ | ||
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', | ||
}, | ||
}); | ||
/* @end */ | ||
``` | ||
|
||
</SnackInline> | ||
|
||
For more advanced examples, check out the [Playlist example](https://github.com/expo/playlist-example/blob/master/App.js), and the [custom `VideoPlayer` controls component](https://github.com/ihmpavel/expo-video-player/blob/master/lib/index.tsx) that wraps `<Video>`, adds custom controls and use the `<Video>` API extensively. The `VideoPlayer` controls is used in [this app](https://github.com/expo/harvard-cs50-app). | ||
|
||
## API | ||
|
||
```js | ||
import { Video } from 'expo-av'; | ||
``` | ||
|
||
<APISection packageName="expo-video-av" apiName="Video(expo-av)" strictTypes /> | ||
|
||
## 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](av/#playback) for further information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.