fusion mp4
This commit is contained in:
@@ -49,14 +49,14 @@ const uploadSourceRecording = async ({ uri, uid, projectId }) => {
|
||||
sourcePath,
|
||||
});
|
||||
|
||||
await uploadFileToFirebase({
|
||||
const { resultURI: videoUrl } = await uploadFileToFirebase({
|
||||
uri,
|
||||
path: sourcePath,
|
||||
shouldCompress: false,
|
||||
fileType: "VIDEO",
|
||||
});
|
||||
|
||||
return { sourcePath };
|
||||
return { sourcePath, videoUrl };
|
||||
};
|
||||
|
||||
const DownloadSongs = ({ route }) => {
|
||||
@@ -78,10 +78,18 @@ const DownloadSongs = ({ route }) => {
|
||||
uri,
|
||||
currentUID,
|
||||
});
|
||||
const audioUrl = project?.songUrl || null;
|
||||
if (!audioUrl) {
|
||||
setTooltip({
|
||||
type: "error",
|
||||
text: "Aucune piste audio disponible pour ce projet",
|
||||
});
|
||||
return;
|
||||
}
|
||||
let tempSourcePath = null;
|
||||
try {
|
||||
setIsLoading(true);
|
||||
const { sourcePath } = await uploadSourceRecording({
|
||||
const { sourcePath, videoUrl } = await uploadSourceRecording({
|
||||
uri,
|
||||
uid: currentUID,
|
||||
projectId: project.id,
|
||||
@@ -90,22 +98,19 @@ const DownloadSongs = ({ route }) => {
|
||||
|
||||
const callable = firebase
|
||||
.functions()
|
||||
.httpsCallable("upload-uploadProjectMedia");
|
||||
.httpsCallable("upload-mergeVideoAndAudio");
|
||||
|
||||
const payload = {
|
||||
sourcePath,
|
||||
projectId: project.id,
|
||||
videoUrl,
|
||||
audioUrl,
|
||||
storagePath: `users/${currentUID}/projects/${project.id}/playback.mp4`,
|
||||
projectField: "playbackUrl",
|
||||
deleteSource: true,
|
||||
metadata: { source: "downloadSongs" },
|
||||
};
|
||||
|
||||
console.log("[DownloadSongs] calling upload-uploadProjectMedia", payload);
|
||||
console.log("[DownloadSongs] calling upload-mergeVideoAndAudio", payload);
|
||||
|
||||
const { data: result } = await callable(payload);
|
||||
|
||||
console.log("[DownloadSongs] upload-uploadProjectMedia result", result);
|
||||
console.log("[DownloadSongs] upload-mergeVideoAndAudio result", result);
|
||||
|
||||
const resultURI = result?.url || null;
|
||||
|
||||
@@ -121,6 +126,16 @@ const DownloadSongs = ({ route }) => {
|
||||
type: "success",
|
||||
text: "Vidéo uploadée",
|
||||
});
|
||||
if (tempSourcePath) {
|
||||
try {
|
||||
await firebase.storage().ref(tempSourcePath).delete();
|
||||
} catch (cleanupError) {
|
||||
console.log("[DownloadSongs] unable to delete temp source", {
|
||||
message: cleanupError?.message,
|
||||
code: cleanupError?.code,
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
setTooltip({
|
||||
type: "error",
|
||||
|
||||
Reference in New Issue
Block a user