diff options
Diffstat (limited to 'apps/web/src/stores/timeline-store.ts')
| -rw-r--r-- | apps/web/src/stores/timeline-store.ts | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/apps/web/src/stores/timeline-store.ts b/apps/web/src/stores/timeline-store.ts index 4b56e6bd..c569ae11 100644 --- a/apps/web/src/stores/timeline-store.ts +++ b/apps/web/src/stores/timeline-store.ts @@ -15,6 +15,7 @@ export interface TimelineTrack { name: string;
type: "video" | "audio" | "effects";
clips: TimelineClip[];
+ muted?: boolean;
}
interface TimelineStore {
@@ -41,6 +42,7 @@ interface TimelineStore { clipId: string,
startTime: number
) => void;
+ toggleTrackMute: (trackId: string) => void;
// Computed values
getTotalDuration: () => number;
@@ -55,6 +57,7 @@ export const useTimelineStore = create<TimelineStore>((set, get) => ({ name: `${type.charAt(0).toUpperCase() + type.slice(1)} Track`,
type,
clips: [],
+ muted: false,
};
set((state) => ({
tracks: [...state.tracks, newTrack],
@@ -125,8 +128,6 @@ export const useTimelineStore = create<TimelineStore>((set, get) => ({ });
},
-
-
updateClipTrim: (trackId, clipId, trimStart, trimEnd) => {
set((state) => ({
tracks: state.tracks.map((track) =>
@@ -134,9 +135,7 @@ export const useTimelineStore = create<TimelineStore>((set, get) => ({ ? {
...track,
clips: track.clips.map((clip) =>
- clip.id === clipId
- ? { ...clip, trimStart, trimEnd }
- : clip
+ clip.id === clipId ? { ...clip, trimStart, trimEnd } : clip
),
}
: track
@@ -151,9 +150,7 @@ export const useTimelineStore = create<TimelineStore>((set, get) => ({ ? {
...track,
clips: track.clips.map((clip) =>
- clip.id === clipId
- ? { ...clip, startTime }
- : clip
+ clip.id === clipId ? { ...clip, startTime } : clip
),
}
: track
@@ -161,13 +158,22 @@ export const useTimelineStore = create<TimelineStore>((set, get) => ({ }));
},
+ toggleTrackMute: (trackId) => {
+ set((state) => ({
+ tracks: state.tracks.map((track) =>
+ track.id === trackId ? { ...track, muted: !track.muted } : track
+ ),
+ }));
+ },
+
getTotalDuration: () => {
const { tracks } = get();
if (tracks.length === 0) return 0;
const trackEndTimes = tracks.map((track) =>
track.clips.reduce((maxEnd, clip) => {
- const clipEnd = clip.startTime + clip.duration - clip.trimStart - clip.trimEnd;
+ const clipEnd =
+ clip.startTime + clip.duration - clip.trimStart - clip.trimEnd;
return Math.max(maxEnd, clipEnd);
}, 0)
);
|
