add background runtime to jellify

This commit is contained in:
Violet Caulfield
2025-02-16 11:36:35 -06:00
parent 5687d86c6e
commit 1ec875faa7
2 changed files with 10 additions and 8 deletions

View File

@@ -11,8 +11,9 @@ import { queryClient } from './constants/query-client';
import { GestureHandlerRootView } from 'react-native-gesture-handler';
import TrackPlayer, { IOSCategory, IOSCategoryOptions } from 'react-native-track-player';
import { CAPABILITIES } from './player/constants';
import { createWorkletRuntime } from 'react-native-reanimated';
// export const backgroundRuntime = createWorkletRuntime('background');
export const backgroundRuntime = createWorkletRuntime('background');
export default function App(): React.JSX.Element {
@@ -51,7 +52,7 @@ export default function App(): React.JSX.Element {
<PersistQueryClientProvider
client={queryClient}
persistOptions={{
persister: clientPersister
persister: clientPersister,
}}>
<GestureHandlerRootView>
<TamaguiProvider config={jellifyConfig}>

View File

@@ -1,4 +1,5 @@
// import { backgroundRuntime } from "@/App";
import { backgroundRuntime } from "../App";
import { runOnRuntime } from "react-native-reanimated";
/**
@@ -9,11 +10,11 @@ import { runOnRuntime } from "react-native-reanimated";
* @see https://emby.media/community/index.php?/topic/63357-runtimeticks-microseconds-milliseconds-or-nanoseconds/
*/
export function convertSecondsToRunTimeTicks(seconds: number) {
// return runOnRuntime(backgroundRuntime, (runTimeSeconds: number) => {
const runTimeMilliseconds = seconds * 1000 * 10000;
return runOnRuntime(backgroundRuntime, (runTimeSeconds: number) => {
const runTimeMilliseconds = runTimeSeconds * 1000 * 10000;
return runTimeMilliseconds;
// })(seconds);
})(seconds);
}
/**
@@ -24,9 +25,9 @@ export function convertSecondsToRunTimeTicks(seconds: number) {
* @see https://emby.media/community/index.php?/topic/63357-runtimeticks-microseconds-milliseconds-or-nanoseconds/
*/
export function convertRunTimeTicksToSeconds(ticks: number) {
// return runOnRuntime(backgroundRuntime, (runTimeTicks : number) => {
const runTimeMilliseconds = ticks / 10000;
return runOnRuntime(backgroundRuntime, (runTimeTicks : number) => {
const runTimeMilliseconds = runTimeTicks / 10000;
const runTimeTotalSeconds = Math.floor(runTimeMilliseconds / 1000);
return runTimeTotalSeconds;
// })(ticks);
})(ticks);
}