removing unused files
This commit is contained in:
parent
410203a5b8
commit
b8363aa993
@ -1,24 +1,11 @@
|
|||||||
/**
|
/**
|
||||||
* Autoplay API
|
* Autoplay API
|
||||||
*
|
*
|
||||||
* Functions to control autoplay settings in the backend.
|
* Functions to control autoplay in the backend.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { invoke } from "@tauri-apps/api/core";
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
|
|
||||||
export interface AutoplaySettings {
|
|
||||||
enabled: boolean;
|
|
||||||
countdownSeconds: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getAutoplaySettings(): Promise<AutoplaySettings> {
|
|
||||||
return invoke("player_get_autoplay_settings");
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function setAutoplaySettings(settings: AutoplaySettings): Promise<AutoplaySettings> {
|
|
||||||
return invoke("player_set_autoplay_settings", { settings });
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function cancelAutoplayCountdown(): Promise<void> {
|
export async function cancelAutoplayCountdown(): Promise<void> {
|
||||||
return invoke("player_cancel_autoplay_countdown");
|
return invoke("player_cancel_autoplay_countdown");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,102 +0,0 @@
|
|||||||
/**
|
|
||||||
* Rust-based conversion utilities via Tauri commands
|
|
||||||
*
|
|
||||||
* These functions provide centralized conversion logic in Rust.
|
|
||||||
* All conversions are handled by the Rust backend for consistency.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { invoke } from '@tauri-apps/api/core';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Format time in seconds to MM:SS display string
|
|
||||||
* @param seconds - Time in seconds
|
|
||||||
* @returns Formatted string like "3:45" or "12:09"
|
|
||||||
*/
|
|
||||||
export async function formatTime(seconds: number): Promise<string> {
|
|
||||||
return invoke('format_time_seconds', { seconds });
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Format time in seconds to HH:MM:SS or MM:SS display string
|
|
||||||
* Automatically chooses format based on duration
|
|
||||||
* @param seconds - Time in seconds
|
|
||||||
* @returns Formatted string like "1:23:45" or "3:45"
|
|
||||||
*/
|
|
||||||
export async function formatTimeLong(seconds: number): Promise<string> {
|
|
||||||
return invoke('format_time_seconds_long', { seconds });
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert Jellyfin ticks to seconds
|
|
||||||
* @param ticks - Time in Jellyfin ticks (10,000,000 ticks = 1 second)
|
|
||||||
* @returns Time in seconds
|
|
||||||
*/
|
|
||||||
export async function ticksToSeconds(ticks: number): Promise<number> {
|
|
||||||
return invoke('convert_ticks_to_seconds', { ticks });
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Calculate progress percentage from position and duration
|
|
||||||
* @param position - Current position in seconds
|
|
||||||
* @param duration - Total duration in seconds
|
|
||||||
* @returns Progress as percentage (0.0 to 100.0)
|
|
||||||
*/
|
|
||||||
export async function calculateProgress(position: number, duration: number): Promise<number> {
|
|
||||||
return invoke('calc_progress', { position, duration });
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert percentage volume (0-100) to normalized (0.0-1.0)
|
|
||||||
* @param percent - Volume as percentage (0 to 100)
|
|
||||||
* @returns Normalized volume (0.0 to 1.0)
|
|
||||||
*/
|
|
||||||
export async function percentToVolume(percent: number): Promise<number> {
|
|
||||||
return invoke('convert_percent_to_volume', { percent });
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Synchronous time formatting utilities for high-frequency UI updates
|
|
||||||
*
|
|
||||||
* These are kept in TypeScript for performance reasons when formatting
|
|
||||||
* needs to happen frequently (e.g., position updates every 100ms).
|
|
||||||
*
|
|
||||||
* For less frequent conversions, prefer the async Rust-based functions above.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Format time in seconds to MM:SS display string (synchronous)
|
|
||||||
* @param seconds - Time in seconds
|
|
||||||
* @returns Formatted string like "3:45" or "12:09"
|
|
||||||
*/
|
|
||||||
export function formatTimeSync(seconds: number): string {
|
|
||||||
const mins = Math.floor(seconds / 60);
|
|
||||||
const secs = Math.floor(seconds % 60);
|
|
||||||
return `${mins}:${secs.toString().padStart(2, '0')}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Format time in seconds to HH:MM:SS or MM:SS display string (synchronous)
|
|
||||||
* @param seconds - Time in seconds
|
|
||||||
* @returns Formatted string like "1:23:45" or "3:45"
|
|
||||||
*/
|
|
||||||
export function formatTimeLongSync(seconds: number): string {
|
|
||||||
const hours = Math.floor(seconds / 3600);
|
|
||||||
const mins = Math.floor((seconds % 3600) / 60);
|
|
||||||
const secs = Math.floor(seconds % 60);
|
|
||||||
|
|
||||||
if (hours > 0) {
|
|
||||||
return `${hours}:${mins.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`;
|
|
||||||
}
|
|
||||||
return `${mins}:${secs.toString().padStart(2, '0')}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Calculate progress percentage (synchronous)
|
|
||||||
* @param position - Current position in seconds
|
|
||||||
* @param duration - Total duration in seconds
|
|
||||||
* @returns Progress as percentage (0 to 100)
|
|
||||||
*/
|
|
||||||
export function calculateProgressSync(position: number, duration: number): number {
|
|
||||||
if (duration <= 0) return 0;
|
|
||||||
return Math.min(100, Math.max(0, (position / duration) * 100));
|
|
||||||
}
|
|
||||||
@ -1,40 +0,0 @@
|
|||||||
/**
|
|
||||||
* Sleep Timer API
|
|
||||||
*
|
|
||||||
* Functions to control the sleep timer in the backend.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { invoke } from "@tauri-apps/api/core";
|
|
||||||
import type { SleepTimerMode } from "$lib/services/playerEvents";
|
|
||||||
|
|
||||||
export interface SleepTimerState {
|
|
||||||
mode: SleepTimerMode;
|
|
||||||
remainingSeconds: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function setSleepTimer(mode: SleepTimerMode): Promise<SleepTimerState> {
|
|
||||||
return invoke("player_set_sleep_timer", { mode });
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function cancelSleepTimer(): Promise<SleepTimerState> {
|
|
||||||
return invoke("player_cancel_sleep_timer");
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getSleepTimer(): Promise<SleepTimerState> {
|
|
||||||
return invoke("player_get_sleep_timer");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Helper functions for common timer modes
|
|
||||||
|
|
||||||
export async function setTimeBasedTimer(minutes: number): Promise<SleepTimerState> {
|
|
||||||
const endTime = Date.now() + minutes * 60 * 1000;
|
|
||||||
return setSleepTimer({ kind: "time", endTime });
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function setEndOfTrackTimer(): Promise<SleepTimerState> {
|
|
||||||
return setSleepTimer({ kind: "endOfTrack" });
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function setEpisodesTimer(count: number): Promise<SleepTimerState> {
|
|
||||||
return setSleepTimer({ kind: "episodes", remaining: count });
|
|
||||||
}
|
|
||||||
@ -1,15 +1,17 @@
|
|||||||
/**
|
/**
|
||||||
* Sleep Timer Store (Display Only - Backend-First Architecture)
|
* Sleep Timer Store (Backend-First Architecture)
|
||||||
*
|
*
|
||||||
* This store reflects sleep timer state from the backend.
|
* This store reflects sleep timer state from the backend.
|
||||||
* All logic is in the Rust backend (PlayerController).
|
* All logic is in the Rust backend (PlayerController).
|
||||||
*
|
*
|
||||||
* The backend emits SleepTimerChanged events to update this store.
|
* The backend emits SleepTimerChanged events to update this store.
|
||||||
|
* Components call store methods which invoke the backend API.
|
||||||
*
|
*
|
||||||
* TRACES: UR-026 | DR-029
|
* TRACES: UR-026 | DR-029
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { writable, derived } from "svelte/store";
|
import { writable, derived } from "svelte/store";
|
||||||
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
|
|
||||||
export type SleepTimerMode =
|
export type SleepTimerMode =
|
||||||
| { kind: "off" }
|
| { kind: "off" }
|
||||||
@ -33,6 +35,30 @@ function createSleepTimerStore() {
|
|||||||
return {
|
return {
|
||||||
subscribe,
|
subscribe,
|
||||||
set, // Updated by playerEvents.ts when backend emits SleepTimerChanged event
|
set, // Updated by playerEvents.ts when backend emits SleepTimerChanged event
|
||||||
|
|
||||||
|
// Methods that invoke the backend API
|
||||||
|
async setTimeTimer(minutes: number): Promise<void> {
|
||||||
|
const endTime = Date.now() + minutes * 60 * 1000;
|
||||||
|
await invoke("player_set_sleep_timer", {
|
||||||
|
mode: { kind: "time", endTime },
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
async setEndOfTrackTimer(): Promise<void> {
|
||||||
|
await invoke("player_set_sleep_timer", {
|
||||||
|
mode: { kind: "endOfTrack" },
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
async setEpisodesTimer(count: number): Promise<void> {
|
||||||
|
await invoke("player_set_sleep_timer", {
|
||||||
|
mode: { kind: "episodes", remaining: count },
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
async cancel(): Promise<void> {
|
||||||
|
await invoke("player_cancel_sleep_timer");
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user