Files
EMI-ExpoAPP/Views/Video.js
T
2022-03-15 21:22:02 -07:00

31 lines
828 B
JavaScript

import * as React from 'react';
import { View, StyleSheet, Button } from 'react-native';
import { Video, AVPlaybackStatus } from 'expo-av';
export default function App({videoUrl}) {
const video = React.useRef(null);
const [status, setStatus] = React.useState({});
return (
<View>
<Video
ref={video}
style={styles.video}
source={{
uri: videoUrl,
}}
useNativeControls
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>
);
}