mirror of
https://github.com/Jellify-Music/App.git
synced 2026-02-23 04:08:48 -06:00
stuff and things around player
This commit is contained in:
1
App.tsx
1
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/`,
|
||||
|
||||
@@ -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 (
|
||||
<JellyfinApiClientProvider>
|
||||
<App />
|
||||
|
||||
@@ -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<JellifyTrack[]>(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);
|
||||
|
||||
Reference in New Issue
Block a user