feat: cut clip from Player mode (X/Z keys, scissors button)
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
28
src/lib/utils/clipRange.ts
Normal file
28
src/lib/utils/clipRange.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
export type QuickClipPosition = 'at' | 'before';
|
||||
|
||||
export function computeQuickClipRange(
|
||||
currentTime: number,
|
||||
duration: number,
|
||||
position: QuickClipPosition,
|
||||
clipDuration = 10,
|
||||
): { start: number; end: number } | null {
|
||||
if (duration === 0) return null;
|
||||
|
||||
switch (position) {
|
||||
case 'at':
|
||||
return {
|
||||
start: currentTime,
|
||||
end: Math.min(currentTime + clipDuration, duration),
|
||||
};
|
||||
case 'before':
|
||||
return {
|
||||
start: Math.max(currentTime - clipDuration, 0),
|
||||
end: currentTime,
|
||||
};
|
||||
default: {
|
||||
const _exhaustive: never = position;
|
||||
void _exhaustive;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user