mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-03-23 09:46:27 +00:00
fix: play flickering bug
This commit is contained in:
@@ -17,6 +17,7 @@ import Animated, {
|
|||||||
import Video from "react-native-video";
|
import Video from "react-native-video";
|
||||||
import { Text } from "./common/Text";
|
import { Text } from "./common/Text";
|
||||||
import { Loader } from "./Loader";
|
import { Loader } from "./Loader";
|
||||||
|
import { debounce } from "lodash";
|
||||||
|
|
||||||
export const CurrentlyPlayingBar: React.FC = () => {
|
export const CurrentlyPlayingBar: React.FC = () => {
|
||||||
const segments = useSegments();
|
const segments = useSegments();
|
||||||
@@ -195,13 +196,7 @@ export const CurrentlyPlayingBar: React.FC = () => {
|
|||||||
onFullscreenPlayerDidDismiss={() => {}}
|
onFullscreenPlayerDidDismiss={() => {}}
|
||||||
onFullscreenPlayerDidPresent={() => {}}
|
onFullscreenPlayerDidPresent={() => {}}
|
||||||
onPlaybackStateChanged={(e) => {
|
onPlaybackStateChanged={(e) => {
|
||||||
if (e.isPlaying) {
|
setIsPlaying(e.isPlaying);
|
||||||
setIsPlaying(true);
|
|
||||||
} else if (e.isSeeking) {
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
setIsPlaying(false);
|
|
||||||
}
|
|
||||||
}}
|
}}
|
||||||
onVolumeChange={(e) => {
|
onVolumeChange={(e) => {
|
||||||
setVolume(e.volume);
|
setVolume(e.volume);
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import { Alert, Platform } from "react-native";
|
|||||||
import { OnProgressData, type VideoRef } from "react-native-video";
|
import { OnProgressData, type VideoRef } from "react-native-video";
|
||||||
import { apiAtom, userAtom } from "./JellyfinProvider";
|
import { apiAtom, userAtom } from "./JellyfinProvider";
|
||||||
import { postCapabilities } from "@/utils/jellyfin/session/capabilities";
|
import { postCapabilities } from "@/utils/jellyfin/session/capabilities";
|
||||||
|
import { debounce } from "lodash";
|
||||||
|
|
||||||
type CurrentlyPlayingState = {
|
type CurrentlyPlayingState = {
|
||||||
url: string;
|
url: string;
|
||||||
@@ -65,7 +66,7 @@ export const PlaybackProvider: React.FC<{ children: ReactNode }> = ({
|
|||||||
|
|
||||||
const previousVolume = useRef<number | null>(null);
|
const previousVolume = useRef<number | null>(null);
|
||||||
|
|
||||||
const [isPlaying, setIsPlaying] = useState<boolean>(false);
|
const [isPlaying, _setIsPlaying] = useState<boolean>(false);
|
||||||
const [isFullscreen, setIsFullscreen] = useState<boolean>(false);
|
const [isFullscreen, setIsFullscreen] = useState<boolean>(false);
|
||||||
const [progressTicks, setProgressTicks] = useState<number | null>(0);
|
const [progressTicks, setProgressTicks] = useState<number | null>(0);
|
||||||
const [volume, _setVolume] = useState<number | null>(null);
|
const [volume, _setVolume] = useState<number | null>(null);
|
||||||
@@ -167,6 +168,13 @@ export const PlaybackProvider: React.FC<{ children: ReactNode }> = ({
|
|||||||
setCurrentlyPlayingState(null);
|
setCurrentlyPlayingState(null);
|
||||||
}, [currentlyPlaying, session, progressTicks]);
|
}, [currentlyPlaying, session, progressTicks]);
|
||||||
|
|
||||||
|
const setIsPlaying = useCallback(
|
||||||
|
debounce((value: boolean) => {
|
||||||
|
_setIsPlaying(value);
|
||||||
|
}, 100),
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
|
||||||
const onProgress = useCallback(
|
const onProgress = useCallback(
|
||||||
({ currentTime }: OnProgressData) => {
|
({ currentTime }: OnProgressData) => {
|
||||||
const ticks = currentTime * 10000000;
|
const ticks = currentTime * 10000000;
|
||||||
|
|||||||
Reference in New Issue
Block a user