diff --git a/components/CurrentlyPlayingBar.tsx b/components/CurrentlyPlayingBar.tsx index de8aa32b..25964c16 100644 --- a/components/CurrentlyPlayingBar.tsx +++ b/components/CurrentlyPlayingBar.tsx @@ -17,6 +17,7 @@ import Animated, { import Video from "react-native-video"; import { Text } from "./common/Text"; import { Loader } from "./Loader"; +import { debounce } from "lodash"; export const CurrentlyPlayingBar: React.FC = () => { const segments = useSegments(); @@ -195,13 +196,7 @@ export const CurrentlyPlayingBar: React.FC = () => { onFullscreenPlayerDidDismiss={() => {}} onFullscreenPlayerDidPresent={() => {}} onPlaybackStateChanged={(e) => { - if (e.isPlaying) { - setIsPlaying(true); - } else if (e.isSeeking) { - return; - } else { - setIsPlaying(false); - } + setIsPlaying(e.isPlaying); }} onVolumeChange={(e) => { setVolume(e.volume); diff --git a/providers/PlaybackProvider.tsx b/providers/PlaybackProvider.tsx index 39c1ebce..1f10909e 100644 --- a/providers/PlaybackProvider.tsx +++ b/providers/PlaybackProvider.tsx @@ -24,6 +24,7 @@ import { Alert, Platform } from "react-native"; import { OnProgressData, type VideoRef } from "react-native-video"; import { apiAtom, userAtom } from "./JellyfinProvider"; import { postCapabilities } from "@/utils/jellyfin/session/capabilities"; +import { debounce } from "lodash"; type CurrentlyPlayingState = { url: string; @@ -65,7 +66,7 @@ export const PlaybackProvider: React.FC<{ children: ReactNode }> = ({ const previousVolume = useRef(null); - const [isPlaying, setIsPlaying] = useState(false); + const [isPlaying, _setIsPlaying] = useState(false); const [isFullscreen, setIsFullscreen] = useState(false); const [progressTicks, setProgressTicks] = useState(0); const [volume, _setVolume] = useState(null); @@ -167,6 +168,13 @@ export const PlaybackProvider: React.FC<{ children: ReactNode }> = ({ setCurrentlyPlayingState(null); }, [currentlyPlaying, session, progressTicks]); + const setIsPlaying = useCallback( + debounce((value: boolean) => { + _setIsPlaying(value); + }, 100), + [] + ); + const onProgress = useCallback( ({ currentTime }: OnProgressData) => { const ticks = currentTime * 10000000;