Files
streamyfin_mirror/components/OfflineVideoPlayer.tsx
Fredrik Burmester 98880e05ec first commit
2024-07-31 23:19:47 +02:00

46 lines
897 B
TypeScript

import React, { useEffect, useRef } from "react";
import Video, { VideoRef } from "react-native-video";
type VideoPlayerProps = {
url: string;
};
export const OfflineVideoPlayer: React.FC<VideoPlayerProps> = ({ url }) => {
const videoRef = useRef<VideoRef | null>(null);
console.log(url);
const onError = (error: any) => {
console.log("Video Error: ", error);
};
useEffect(() => {
if (videoRef.current) {
videoRef.current.resume();
}
setTimeout(() => {
if (videoRef.current) {
videoRef.current.presentFullscreenPlayer();
}
}, 500);
}, []);
return (
<Video
source={{
uri: url,
isNetwork: false,
}}
controls
ref={videoRef}
onError={onError}
resizeMode="contain"
reportBandwidth
style={{
width: "100%",
aspectRatio: 16 / 9,
}}
/>
);
};