Update
This commit is contained in:
@@ -13,6 +13,8 @@ const useVideoExport = ({ timelineElements, dimensions, totalDuration, watermark
|
||||
const [isExporting, setIsExporting] = useState(false);
|
||||
const [exportProgress, setExportProgress] = useState(0);
|
||||
const [exportStatus, setExportStatus] = useState('');
|
||||
const [videoBlob, setVideoBlob] = useState(null);
|
||||
const [videoBlobFilename, setVideoBlobFilename] = useState(null);
|
||||
|
||||
useEffect(() => {
|
||||
console.log(JSON.stringify(timelineElements));
|
||||
@@ -692,43 +694,9 @@ const useVideoExport = ({ timelineElements, dimensions, totalDuration, watermark
|
||||
const epochTimestamp = Date.now();
|
||||
const fileName = `memeaigen-${epochTimestamp}.mp4`;
|
||||
|
||||
// Check if mobile and supports navigator.share
|
||||
const isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
|
||||
const canShare = isMobile && navigator.share && navigator.canShare;
|
||||
|
||||
if (canShare) {
|
||||
try {
|
||||
const files = [new File([blob], fileName, { type: "video/mp4" })];
|
||||
if (navigator.canShare({ files })) {
|
||||
await navigator.share({ files });
|
||||
} else {
|
||||
// Fallback to download if sharing files isn't supported
|
||||
const url = URL.createObjectURL(blob);
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.download = fileName;
|
||||
link.click();
|
||||
URL.revokeObjectURL(url);
|
||||
}
|
||||
} catch (shareError) {
|
||||
console.log('Share failed, falling back to download:', shareError);
|
||||
// Fallback to download
|
||||
const url = URL.createObjectURL(blob);
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.download = fileName;
|
||||
link.click();
|
||||
URL.revokeObjectURL(url);
|
||||
}
|
||||
} else {
|
||||
// Desktop or unsupported mobile - use download
|
||||
const url = URL.createObjectURL(blob);
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.download = fileName;
|
||||
link.click();
|
||||
URL.revokeObjectURL(url);
|
||||
}
|
||||
// Store the blob and filename in state instead of auto-downloading
|
||||
setVideoBlob(blob);
|
||||
setVideoBlobFilename(fileName);
|
||||
|
||||
setExportProgress(100);
|
||||
setExportStatus('Complete!');
|
||||
@@ -763,6 +731,8 @@ const useVideoExport = ({ timelineElements, dimensions, totalDuration, watermark
|
||||
exportProgress,
|
||||
exportStatus,
|
||||
ffmpegCommand,
|
||||
videoBlob,
|
||||
videoBlobFilename,
|
||||
|
||||
// Functions
|
||||
copyFFmpegCommand,
|
||||
|
||||
Reference in New Issue
Block a user