mirror of
https://github.com/streamyfin/streamyfin.git
synced 2025-08-20 18:37:18 +02:00
44 lines
878 B
TypeScript
44 lines
878 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);
|
|
|
|
const onError = (error: any) => {
|
|
console.error("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,
|
|
}}
|
|
/>
|
|
);
|
|
};
|