diff --git a/front/components/Play/PartitionMagic.tsx b/front/components/Play/PartitionMagic.tsx index 2961aa5..e4b2365 100644 --- a/front/components/Play/PartitionMagic.tsx +++ b/front/components/Play/PartitionMagic.tsx @@ -78,6 +78,8 @@ const PartitionMagic = ({ const cursorTop = (data?.cursors[cursorDisplayIdx]?.y ?? 0) - cursorPaddingVertical; const cursorLeft = (data?.cursors[0]?.x ?? 0) - cursorPaddingHorizontal; + console.log(melodySound.current?._loaded); + if (!endPartitionReached && currentCurIdx.current + 1 === data?.cursors.length) { // weird contraption but the mobile don't want classic functions to be called // with the withTiming function :( @@ -86,7 +88,7 @@ const PartitionMagic = ({ React.useEffect(() => { // In practice mode, no sound is played so just act as the piano is loaded - if (playType === 'practice' || playType === undefined) { + if (playType === 'practice' || !playType) { setIsPianoLoaded(true); return; } @@ -120,7 +122,7 @@ const PartitionMagic = ({ piano.current = null; } }; - }, []); + }, [playType]); const partitionDims = React.useMemo<[number, number]>(() => { return [data?.pageWidth ?? 0, data?.pageHeight ?? 1]; }, [data]); diff --git a/front/views/PlayView.tsx b/front/views/PlayView.tsx index 0bac409..c65dbf1 100644 --- a/front/views/PlayView.tsx +++ b/front/views/PlayView.tsx @@ -74,7 +74,7 @@ const PlayView = ({ songId }: PlayViewProps) => { const songHistory = useQuery(API.getSongHistory(songId)); const endCalled = useRef(false); const [score, setScore] = useState(0); // Between 0 and 100 - const getElapsedTime = () => stopwatch.getElapsedRunningTime() - 3000; + const getElapsedTime = () => stopwatch.getElapsedRunningTime(); const [readyToPlay, setReadyToPlay] = useState(false); // eslint-disable-next-line @typescript-eslint/no-unused-vars const [midiKeyboardFound, setMidiKeyboardFound] = useState(); @@ -444,7 +444,9 @@ const PlayView = ({ songId }: PlayViewProps) => { setShouldPlay(false); }} onResume={() => { - setShouldPlay(true); + setTimeout(() => { + setShouldPlay(true); + }, 3000); }} />