playbacks record
This commit is contained in:
@@ -32,12 +32,23 @@ const guessExtension = (inputUri = "") => {
|
||||
};
|
||||
|
||||
const uploadSourceRecording = async ({ uri, uid, projectId }) => {
|
||||
console.log("[DownloadSongs] uploadSourceRecording params", {
|
||||
hasUri: Boolean(uri),
|
||||
uid,
|
||||
projectId,
|
||||
});
|
||||
|
||||
if (!uri) throw new Error("Aucune vidéo trouvée");
|
||||
if (!uid) throw new Error("Utilisateur non authentifié");
|
||||
|
||||
const extension = guessExtension(uri);
|
||||
const sourcePath = `users/${uid}/projects/${projectId}/recordings/source-${Date.now()}.${extension}`;
|
||||
|
||||
console.log("[DownloadSongs] uploadSourceRecording source path", {
|
||||
extension,
|
||||
sourcePath,
|
||||
});
|
||||
|
||||
await uploadFileToFirebase({
|
||||
uri,
|
||||
path: sourcePath,
|
||||
@@ -51,13 +62,22 @@ const uploadSourceRecording = async ({ uri, uid, projectId }) => {
|
||||
const DownloadSongs = ({ route }) => {
|
||||
const { currentUID } = useUserData();
|
||||
const { action, uri, project } = route.params || {};
|
||||
console.log("project id", project?.id);
|
||||
console.log("[DownloadSongs] route params", {
|
||||
action,
|
||||
projectId: project?.id,
|
||||
hasUri: Boolean(uri),
|
||||
currentUID,
|
||||
});
|
||||
const { setIsLoading, setTooltip } = useMinuit();
|
||||
|
||||
const handleDownloadUri = async () => {
|
||||
if (action === "playback" && project?.id) {
|
||||
// Publication du playback
|
||||
console.log("project id : ", project.id);
|
||||
console.log("[DownloadSongs] handleDownloadUri playback", {
|
||||
projectId: project.id,
|
||||
uri,
|
||||
currentUID,
|
||||
});
|
||||
let tempSourcePath = null;
|
||||
try {
|
||||
setIsLoading(true);
|
||||
@@ -72,14 +92,20 @@ const DownloadSongs = ({ route }) => {
|
||||
.functions()
|
||||
.httpsCallable("upload-uploadProjectMedia");
|
||||
|
||||
const { data: result } = await callable({
|
||||
const payload = {
|
||||
sourcePath,
|
||||
projectId: project.id,
|
||||
storagePath: `users/${currentUID}/projects/${project.id}/playback.mp4`,
|
||||
projectField: "playbackUrl",
|
||||
deleteSource: true,
|
||||
metadata: { source: "downloadSongs" },
|
||||
});
|
||||
};
|
||||
|
||||
console.log("[DownloadSongs] calling upload-uploadProjectMedia", payload);
|
||||
|
||||
const { data: result } = await callable(payload);
|
||||
|
||||
console.log("[DownloadSongs] upload-uploadProjectMedia result", result);
|
||||
|
||||
const resultURI = result?.url || null;
|
||||
|
||||
@@ -102,7 +128,12 @@ const DownloadSongs = ({ route }) => {
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("[DownloadSongs] error upload playback", error);
|
||||
console.log("[DownloadSongs] error upload playback", {
|
||||
message: error?.message,
|
||||
code: error?.code,
|
||||
name: error?.name,
|
||||
details: error?.details,
|
||||
});
|
||||
if (tempSourcePath) {
|
||||
try {
|
||||
await firebase.storage().ref(tempSourcePath).delete();
|
||||
@@ -110,7 +141,9 @@ const DownloadSongs = ({ route }) => {
|
||||
}
|
||||
setTooltip({
|
||||
type: "error",
|
||||
text: String(error?.message || "Erreur lors de la publication du playback"),
|
||||
text: String(
|
||||
error?.message || "Erreur lors de la publication du playback"
|
||||
),
|
||||
});
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
|
||||
Reference in New Issue
Block a user