From 8223b572b90d52bdfa07664430a5d68b50cf1437 Mon Sep 17 00:00:00 2001 From: leon-morival Date: Tue, 2 Sep 2025 15:08:59 +0200 Subject: [PATCH] save playback --- src/screens/Playback/RecordedPlayback.js | 11 ++- src/screens/Production/DownloadSongs.js | 95 ++++++++++++++++++------ src/screens/ProjectSettings.js | 13 ++-- 3 files changed, 91 insertions(+), 28 deletions(-) diff --git a/src/screens/Playback/RecordedPlayback.js b/src/screens/Playback/RecordedPlayback.js index e2076be..cfeed6e 100644 --- a/src/screens/Playback/RecordedPlayback.js +++ b/src/screens/Playback/RecordedPlayback.js @@ -141,7 +141,16 @@ const RecordedPlayback = ({ route }) => { - + { + navigate(Routes.DownloadSongs, { + action: "playback", + uri: videoUri, + project, + }); + }} + /> { diff --git a/src/screens/Production/DownloadSongs.js b/src/screens/Production/DownloadSongs.js index c2fd62a..9b96a4a 100644 --- a/src/screens/Production/DownloadSongs.js +++ b/src/screens/Production/DownloadSongs.js @@ -1,29 +1,76 @@ -import { - View, - Text, - StyleSheet, - Image, - Pressable, - Platform, -} from "react-native"; +import { BlurView } from "expo-blur"; import React from "react"; -import Page from "../../layouts/Page"; +import { + Image, + Platform, + Pressable, + StyleSheet, + Text, + View, +} from "react-native"; +import useMinuit from "react-native-minuit/src/hooks/useMinuit.js"; +import { responsiveHeight } from "react-native-responsive-dimensions"; import { background, img } from "../../assets"; import MusicLandHeader from "../../components/MusicLandHeader"; +import { projectsRef, serverTimestamp } from "../../config/firebase"; +import { uploadFileToFirebase } from "../../helpers/uploadToFirebase"; +import Page from "../../layouts/Page"; +import { Routes } from "../../navigation"; import { goBack, navigate } from "../../navigation/NavigationService"; import { Palette } from "../../styles"; import { FONT_FAMILY } from "../../styles/Fonts"; -import CreateLyricsHeader from "../Writing/components/CreateLyricsHeader"; + import { size } from "../../styles/Style"; -import { BlurView } from "expo-blur"; -import { responsiveHeight } from "react-native-responsive-dimensions"; -import { Routes } from "../../navigation"; -import { useRoute } from "@react-navigation/core"; +import CreateLyricsHeader from "../Writing/components/CreateLyricsHeader"; +const DownloadSongs = ({ route }) => { + // const params = useRoute().params; + const { action, uri, project } = route.params || {}; + console.log("project id", project?.id); + const { setIsLoading, setTooltip } = useMinuit(); -const DownloadSongs = () => { - const params = useRoute().params; - const action = params?.action; + const handleDownloadUri = async () => { + if (action === "playback" && project?.id) { + // Publication du playback + try { + setIsLoading(true); + const { resultURI = null } = await uploadFileToFirebase({ + uri: uri, + path: `musics/${project.id}/playback.mp4`, + }); + if (!resultURI) throw new Error("Téléversement de l'image impossible"); + + if (resultURI) { + await projectsRef.doc(project.id).set( + { + playbackUrl: resultURI, + updatedAt: serverTimestamp(), + }, + { merge: true } + ); + setTooltip({ + type: "success", + text: "Playback publié avec succès", + }); + } else { + setTooltip({ + type: "error", + text: "Erreur lors de la publication du playback", + }); + } + } catch (error) { + setTooltip({ + type: "error", + text: "Erreur lors de la publication du playback", + }); + } finally { + setIsLoading(false); + } + // Handle playback download + } else { + // Handle song download + } + }; return ( { - navigate(Routes.DownloadPrices, { - action, - }) + onPress={ + () => { + console.log("test"); + handleDownloadUri(); + } + + // navigate(Routes.DownloadPrices, { + // action, + // uri, + // }) } > { const { setIsLoading, setTooltip } = useMinuit();