-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
51 lines (48 loc) · 1.47 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { AVPlaybackStatus, ResizeMode, Video } from "expo-av";
import { StatusBar } from "expo-status-bar";
import { useRef, useState } from "react";
import { Button, StyleSheet, Text, View } from "react-native";
export default function App() {
const video = useRef<Video>(null);
const [status, setStatus] = useState<AVPlaybackStatus>();
return (
<View style={styles.container}>
<StatusBar style="auto" />
<Video
ref={video}
style={styles.video}
source={{
// uri: "https://d23dyxeqlo5psv.cloudfront.net/big_buck_bunny.mp4", // mp4 video works fine
uri: "https://demo.unified-streaming.com/k8s/features/stable/video/tears-of-steel/tears-of-steel.ism/.m3u8", // HLS video - you can hear only soud, but don't see the video picture
}}
// useNativeControls
resizeMode={ResizeMode.CONTAIN}
isLooping
onPlaybackStatusUpdate={(status) => setStatus(() => status)}
/>
{!!status?.isLoaded && (
<Button
title={status?.isPlaying ? "Pause" : "Play"}
onPress={() =>
status?.isPlaying
? video.current?.pauseAsync()
: video.current?.playAsync()
}
/>
)}
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center",
},
video: {
width: "100%",
height: 300,
backgroundColor: "#cccccc",
},
});