mirror of
https://github.com/movie-web/native-app.git
synced 2025-09-13 14:23:28 +00:00
Merge branch 'feat-providers-video' of https://github.com/castdrian/mw-native into pr/9
This commit is contained in:
@@ -39,6 +39,7 @@ const VideoPlayer: React.FC<VideoPlayerProps> = ({ data }) => {
|
|||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
const [headerData, setHeaderData] = useState<HeaderData>();
|
const [headerData, setHeaderData] = useState<HeaderData>();
|
||||||
const [resizeMode, setResizeMode] = useState(ResizeMode.CONTAIN);
|
const [resizeMode, setResizeMode] = useState(ResizeMode.CONTAIN);
|
||||||
|
const [shouldPlay, setShouldPlay] = useState(true);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const scale = useSharedValue(1);
|
const scale = useSharedValue(1);
|
||||||
const setVideoRef = usePlayerStore((state) => state.setVideoRef);
|
const setVideoRef = usePlayerStore((state) => state.setVideoRef);
|
||||||
@@ -65,6 +66,18 @@ const VideoPlayer: React.FC<VideoPlayerProps> = ({ data }) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const togglePlayback = () => {
|
||||||
|
setShouldPlay(!shouldPlay);
|
||||||
|
};
|
||||||
|
|
||||||
|
const doubleTapGesture = Gesture.Tap()
|
||||||
|
.numberOfTaps(2)
|
||||||
|
.onEnd(() => {
|
||||||
|
runOnJS(togglePlayback)();
|
||||||
|
});
|
||||||
|
|
||||||
|
const composedGesture = Gesture.Exclusive(pinchGesture, doubleTapGesture);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const initializePlayer = async () => {
|
const initializePlayer = async () => {
|
||||||
if (!data) {
|
if (!data) {
|
||||||
@@ -139,13 +152,13 @@ const VideoPlayer: React.FC<VideoPlayerProps> = ({ data }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<GestureDetector gesture={pinchGesture}>
|
<GestureDetector gesture={composedGesture}>
|
||||||
<View className="flex-1 items-center justify-center bg-black">
|
<View className="flex-1 items-center justify-center bg-black">
|
||||||
<Video
|
<Video
|
||||||
ref={setVideoRef}
|
ref={setVideoRef}
|
||||||
source={videoSrc}
|
source={videoSrc}
|
||||||
shouldPlay
|
shouldPlay={shouldPlay}
|
||||||
resizeMode={ResizeMode.CONTAIN}
|
resizeMode={resizeMode}
|
||||||
onLoadStart={onVideoLoadStart}
|
onLoadStart={onVideoLoadStart}
|
||||||
onReadyForDisplay={onReadyForDisplay}
|
onReadyForDisplay={onReadyForDisplay}
|
||||||
onPlaybackStatusUpdate={setStatus}
|
onPlaybackStatusUpdate={setStatus}
|
||||||
|
Reference in New Issue
Block a user