Skip to content

Commit

Permalink
Add a toast to let the user know ffmpeg is working
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanseddon committed Dec 2, 2024
1 parent fc990e2 commit 6f23f77
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/components/ffmpeg-provider.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useState, createContext, ReactNode } from "react";
import { FFmpeg } from "@/lib/FFmpeg";
import { useToast } from "@/hooks/use-toast";

export type FFmpegContextType = {
loading: boolean;
Expand All @@ -14,6 +15,7 @@ export const FFmpegProvider: React.FC<{
children: ReactNode;
}> = ({ children }) => {
const [ffmpeg] = useState(new FFmpeg());
const { toast } = useToast();
const [loading, setLoading] = useState(false);

const loadFFmpeg = async (): Promise<FFmpeg["ffmpeg"]> => {
Expand All @@ -36,6 +38,12 @@ export const FFmpegProvider: React.FC<{

console.log(`ffmpeg ${command.join(" ")}`);

const timeoutId = setTimeout(() => {
toast({
title: "This operation might take a bit",
description: "Check the dev tools console to see ffmpeg progress",
});
}, 5000);
try {
const ffmpeg = await loadFFmpeg();

Expand All @@ -49,6 +57,8 @@ export const FFmpegProvider: React.FC<{
} catch (err) {
console.error(err);
throw err;
} finally {
clearTimeout(timeoutId);
}
};

Expand Down

0 comments on commit 6f23f77

Please sign in to comment.