Squash merge feature/library-reorganization
This commit is contained in:
26
frontend/src/lib/media.ts
Normal file
26
frontend/src/lib/media.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
function formatSecondsValue(milliseconds: number): string {
|
||||
return (milliseconds / 1000).toFixed(1);
|
||||
}
|
||||
|
||||
export function formatClipRange(startMs: number, endMs: number): string {
|
||||
return `${formatSecondsValue(startMs)}s to ${formatSecondsValue(endMs)}s`;
|
||||
}
|
||||
|
||||
export function formatPlaybackPosition(milliseconds: number): string {
|
||||
const roundedSeconds = Math.round(Math.max(0, milliseconds) / 100) / 10;
|
||||
const wholeSeconds = Math.floor(roundedSeconds);
|
||||
const tenths = Math.round((roundedSeconds - wholeSeconds) * 10);
|
||||
const hours = Math.floor(wholeSeconds / 3600);
|
||||
const minutes = Math.floor((wholeSeconds % 3600) / 60);
|
||||
const seconds = wholeSeconds % 60;
|
||||
|
||||
if (hours > 0) {
|
||||
return `${hours}:${String(minutes).padStart(2, "0")}:${String(seconds).padStart(2, "0")}.${tenths}`;
|
||||
}
|
||||
|
||||
if (minutes > 0) {
|
||||
return `${minutes}:${String(seconds).padStart(2, "0")}.${tenths}`;
|
||||
}
|
||||
|
||||
return `${seconds}.${tenths}s`;
|
||||
}
|
||||
Reference in New Issue
Block a user