mirror of
https://github.com/movie-web/native-app.git
synced 2025-09-13 13:13:25 +00:00
add play and seek buttons
This commit is contained in:
29
apps/expo/src/components/player/PlayButton.tsx
Normal file
29
apps/expo/src/components/player/PlayButton.tsx
Normal file
@@ -0,0 +1,29 @@
|
||||
import { FontAwesome } from "@expo/vector-icons";
|
||||
|
||||
import { usePlayerStore } from "~/stores/player/store";
|
||||
|
||||
export const PlayButton = () => {
|
||||
const videoRef = usePlayerStore((state) => state.videoRef);
|
||||
const status = usePlayerStore((state) => state.status);
|
||||
|
||||
return (
|
||||
<FontAwesome
|
||||
name={status?.isLoaded && status.isPlaying ? "pause" : "play"}
|
||||
size={36}
|
||||
color="white"
|
||||
onPress={() => {
|
||||
if (status?.isLoaded) {
|
||||
if (status.isPlaying) {
|
||||
videoRef?.pauseAsync().catch(() => {
|
||||
console.log("Error pausing video");
|
||||
});
|
||||
} else {
|
||||
videoRef?.playAsync().catch(() => {
|
||||
console.log("Error playing video");
|
||||
});
|
||||
}
|
||||
}
|
||||
}}
|
||||
/>
|
||||
);
|
||||
};
|
Reference in New Issue
Block a user