Skip to content

Commit 5609d72

Browse files
committed
feat(mobile): video player
1 parent 4e2cdbe commit 5609d72

File tree

4 files changed

+39
-12
lines changed

4 files changed

+39
-12
lines changed

apps/mobile/app.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ export default ({ config }: ConfigContext): ExpoConfig => ({
118118
photosPermission: "Allow $(PRODUCT_NAME) to access your photos.",
119119
},
120120
],
121+
"react-native-video",
121122
],
122123
experiments: {
123124
typedRoutes: true,

apps/mobile/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
"react-native-svg": "15.8.0",
101101
"react-native-track-player": "4.1.1",
102102
"react-native-uikit-colors": "0.3.8",
103+
"react-native-video": "6.10.2",
103104
"react-native-volume-manager": "2.0.8",
104105
"react-native-web": "0.19.13",
105106
"react-native-webview": "13.12.5",

apps/mobile/src/components/ui/carousel/MediaCarousel.tsx

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import Animated, {
66
useSharedValue,
77
withSpring,
88
} from "react-native-reanimated"
9+
import Video from "react-native-video"
910

1011
import { Galeria } from "@/src/components/ui/image/galeria"
1112
import type { MediaModel } from "@/src/database/schemas/types"
@@ -32,6 +33,8 @@ export const MediaCarousel = ({
3233
// const activeIndex = useSharedValue(0)
3334
const [activeIndex, setActiveIndex] = useState(0)
3435

36+
const [isVideoInFullscreen, setIsVideoInFullscreen] = useState(false)
37+
3538
return (
3639
<View
3740
onLayout={(e) => {
@@ -78,17 +81,25 @@ export const MediaCarousel = ({
7881
</ImageContextMenu>
7982
</View>
8083
)
81-
} else if (m.preview_image_url) {
82-
// TODO: video preview
84+
} else if (m.type === "video") {
8385
return (
84-
<Image
85-
key={index}
86-
source={{ uri: m.preview_image_url }}
87-
aspectRatio={aspectRatio}
88-
/>
86+
<ImageContextMenu key={index} entryId={entryId} imageUrl={m.url}>
87+
<Video
88+
source={{ uri: m.url }}
89+
style={{ width: containerWidth, height: containerHeight }}
90+
muted={!isVideoInFullscreen}
91+
repeat
92+
poster={{
93+
source: { uri: m.preview_image_url },
94+
resizeMode: "cover",
95+
}}
96+
controls
97+
onFullscreenPlayerWillPresent={() => setIsVideoInFullscreen(true)}
98+
onFullscreenPlayerWillDismiss={() => setIsVideoInFullscreen(false)}
99+
/>
100+
</ImageContextMenu>
89101
)
90102
} else {
91-
// TODO: video preview
92103
return null
93104
}
94105
})}

pnpm-lock.yaml

Lines changed: 18 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)