This commit is contained in:
ct
2025-07-03 16:34:21 +08:00
parent 0dd7d82502
commit f183d1ff13
10 changed files with 246 additions and 39 deletions

View File

@@ -689,13 +689,46 @@ const useVideoExport = ({ timelineElements, dimensions, totalDuration, watermark
const data = new Uint8Array(fileData);
const blob = new Blob([data.buffer], { type: 'video/mp4' });
const url = URL.createObjectURL(blob);
const epochTimestamp = Date.now();
const fileName = `memeaigen-${epochTimestamp}.mp4`;
const link = document.createElement('a');
link.href = url;
link.download = 'exported_video.mp4';
link.click();
URL.revokeObjectURL(url);
// 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);
}
setExportProgress(100);
setExportStatus('Complete!');