diff --git a/App.tsx b/App.tsx index 64d75b60..1ddf0a5c 100644 --- a/App.tsx +++ b/App.tsx @@ -11,6 +11,7 @@ import { clientPersister } from './constants/storage'; import { queryClient } from './constants/query-client'; import { CacheManager } from '@georstat/react-native-image-cache'; import { Dirs } from "react-native-file-access"; +import { usePlayer } from './player/queries'; CacheManager.config = { baseDir: `${Dirs.CacheDir}/images_cache/`, diff --git a/components/jellify.tsx b/components/jellify.tsx index df77b7d3..c8f7cead 100644 --- a/components/jellify.tsx +++ b/components/jellify.tsx @@ -1,9 +1,7 @@ -import { useColorScheme } from "react-native"; -import { setupPlayer } from "react-native-track-player/lib/src/trackPlayer"; import _ from "lodash"; import { JellyfinApiClientProvider, useApiClientContext } from "./jellyfin-api-provider"; import React from "react"; -import { DarkTheme, DefaultTheme, NavigationContainer } from "@react-navigation/native"; +import { NavigationContainer } from "@react-navigation/native"; import Navigation from "./navigation"; import Login from "./Login/component"; import { JellyfinAuthenticationProvider } from "./Login/provider"; @@ -13,8 +11,6 @@ import { PlayerProvider } from "../player/provider"; export default function Jellify(): React.JSX.Element { - setupPlayer(); - return ( diff --git a/player/provider.tsx b/player/provider.tsx index 67af5a41..a1891c45 100644 --- a/player/provider.tsx +++ b/player/provider.tsx @@ -4,7 +4,7 @@ import { storage } from "../constants/storage"; import { MMKVStorageKeys } from "../enums/mmkv-storage-keys"; import { useActiveTrack, useProgress } from "react-native-track-player"; import { findPlayQueueIndexStart } from "./mutators/helpers"; -import { add, remove, removeUpcomingTracks } from "react-native-track-player/lib/src/trackPlayer"; +import { add, remove, removeUpcomingTracks, setupPlayer } from "react-native-track-player/lib/src/trackPlayer"; import _ from "lodash"; interface PlayerContext { @@ -31,6 +31,8 @@ const PlayerContextInitializer = () => { const [queue, setQueue] = useState(queueJson ? JSON.parse(queueJson) : []); //#region RNTP Setup + setupPlayer(); + const [playerState, setPlayerState] = useState(null); const { position, buffered, duration } = useProgress() @@ -38,12 +40,14 @@ const PlayerContextInitializer = () => { //#endregion RNTP Setup const clearQueue = async () => { + console.debug("Clearing queue") await removeUpcomingTracks(); await remove(0) setQueue([]); } const addToQueue = async (tracks: JellifyTrack[]) => { + console.debug(`Adding ${tracks.length} to queue`) let insertIndex = findPlayQueueIndexStart(queue); await add(tracks, insertIndex);