mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-07-16 17:33:00 +01:00
feat: KSPlayer as an option for iOS + other improvements (#1266)
This commit is contained in:
committed by
GitHub
parent
d1795c9df8
commit
74d86b5d12
@@ -99,3 +99,21 @@ export const msToSeconds = (ms?: number | undefined) => {
|
||||
if (!ms) return 0;
|
||||
return Math.floor(ms / 1000);
|
||||
};
|
||||
|
||||
/**
|
||||
* Formats ticks to a compact duration string (MM:SS or HH:MM:SS).
|
||||
* Useful for music track durations.
|
||||
*/
|
||||
export const formatDuration = (ticks: number | null | undefined): string => {
|
||||
if (!ticks) return "0:00";
|
||||
|
||||
const totalSeconds = Math.floor(ticks / 10000000);
|
||||
const hours = Math.floor(totalSeconds / 3600);
|
||||
const minutes = Math.floor((totalSeconds % 3600) / 60);
|
||||
const seconds = totalSeconds % 60;
|
||||
|
||||
if (hours > 0) {
|
||||
return `${hours}:${minutes.toString().padStart(2, "0")}:${seconds.toString().padStart(2, "0")}`;
|
||||
}
|
||||
return `${minutes}:${seconds.toString().padStart(2, "0")}`;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user