Skip to content

Commit

Permalink
Merge pull request #91 from devniel/main
Browse files Browse the repository at this point in the history
refactor: add try/catch to saveVideoFile
  • Loading branch information
devniel authored Sep 1, 2024
2 parents 666c3ce + 8850793 commit 13dbe01
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions packages/app/src/services/io/useIO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,15 @@ export const useIO = create<IOStore>((set, get) => ({
const { saveAnyFile } = get()
console.log(`rendering project using the embedded FFmpeg..`)

const task = useTasks.getState().add({
category: TaskCategory.EXPORT,
visibility: TaskVisibility.BLOCKER,
initialMessage: `Rendering the project to MP4..`,
successMessage: `Successfully exported the MP4 video!`,
value: 0,
})

try {
const timeline: TimelineStore = useTimeline.getState()

const {
Expand All @@ -540,14 +549,6 @@ export const useIO = create<IOStore>((set, get) => ({
throw new Error(`cannot save a clap.. if there is no clap`)
}

const task = useTasks.getState().add({
category: TaskCategory.EXPORT,
visibility: TaskVisibility.BLOCKER,
initialMessage: `Rendering the project to MP4..`,
successMessage: `Successfully exported the MP4 video!`,
value: 0,
})

const ignoreThisVideoSegmentId = (await getFinalVideo(clap))?.id || ''

const segments: ExportableSegment[] = timelineSegments
Expand Down Expand Up @@ -633,6 +634,10 @@ export const useIO = create<IOStore>((set, get) => ({
const videoBlob = new Blob([fullVideo], { type: 'video/mp4' })
saveAnyFile(videoBlob, 'my_project.mp4')
task.success()
} catch (err) {
console.error(err)
task.fail(`${err || 'unknown error'}`)
}
},

saveZipFile: async () => {
Expand Down

0 comments on commit 13dbe01

Please sign in to comment.