music timestamps
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
import React, { useCallback, useState } from "react";
|
||||
import { Alert, Image, StyleSheet, View } from "react-native";
|
||||
import useMinuit from "react-native-minuit/src/hooks/useMinuit.js";
|
||||
import { Image, StyleSheet, View } from "react-native";
|
||||
import { ai, background } from "../../assets";
|
||||
import BorderGradientButton from "../../components/BorderGradientButton";
|
||||
import GradientButton from "../../components/GradientButton";
|
||||
import MusicLandHeader from "../../components/MusicLandHeader";
|
||||
import firebase from "../../config/firebase";
|
||||
import Page from "../../layouts/Page";
|
||||
import { Routes } from "../../navigation";
|
||||
import { goBack, navigate } from "../../navigation/NavigationService";
|
||||
@@ -14,52 +12,13 @@ import FullscreenIntroVideo from "../../components/FullscreenIntroVideo";
|
||||
|
||||
const Playback = ({ route }) => {
|
||||
const { project } = route.params;
|
||||
const projectId = project?.id;
|
||||
const songIndex = project?.songIndex;
|
||||
const sunoTaskId = project?.sunoTaskId;
|
||||
const { setIsLoading } = useMinuit();
|
||||
const [showIntro, setShowIntro] = useState(false);
|
||||
|
||||
const onPressRecord = useCallback(async () => {
|
||||
try {
|
||||
if (!projectId || songIndex === undefined || !sunoTaskId) {
|
||||
return;
|
||||
// return navigate(Routes.RecordPlayback, { project });
|
||||
}
|
||||
if (project?.musicTimestamps?.[songIndex]) {
|
||||
console.log("exists");
|
||||
return navigate(Routes.RecordPlayback, { project });
|
||||
}
|
||||
|
||||
await setIsLoading(true);
|
||||
const callable = firebase
|
||||
.functions()
|
||||
.httpsCallable("music-getSunoTimestamps");
|
||||
const { data } = await callable({
|
||||
taskId: sunoTaskId,
|
||||
musicIndex: Number(songIndex) || 0,
|
||||
projectId: projectId,
|
||||
});
|
||||
|
||||
if (!data?.success) {
|
||||
console.log("getSunoTimestamps failed", data?.error || data);
|
||||
Alert.alert(
|
||||
"Timestamps",
|
||||
"Impossible de récupérer les timestamps pour ce playback pour le moment. Tu peux quand même continuer.",
|
||||
);
|
||||
}
|
||||
|
||||
await setIsLoading(false);
|
||||
navigate(Routes.RecordPlayback, { project });
|
||||
} catch (e) {
|
||||
console.log("getSunoTimestamps error", e?.message || e);
|
||||
Alert.alert(
|
||||
"Timestamps",
|
||||
"Une erreur est survenue lors de la génération des timestamps. Tu peux quand même continuer.",
|
||||
);
|
||||
await setIsLoading(false);
|
||||
}
|
||||
}, [projectId, songIndex, sunoTaskId, project, setIsLoading]);
|
||||
const onPressRecord = useCallback(() => {
|
||||
// Les timestamps sont désormais générés automatiquement côté serveur
|
||||
// lors de la mise à jour du document (si songUrl existe).
|
||||
navigate(Routes.RecordPlayback, { project });
|
||||
}, [project]);
|
||||
|
||||
return (
|
||||
<Page headerType="NONE" backgroundImg={background.playbackBG2}>
|
||||
|
||||
Reference in New Issue
Block a user