From 8adf8da824aee94e126b4001100ab9f175126bfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Poullet-Pag=C3=A8s?= Date: Thu, 16 Jan 2025 13:32:55 +0100 Subject: [PATCH] conditionnal render player --- src/features/score/MeiViewer.jsx | 21 ++++++++++- src/features/score/Player.jsx | 65 +++++++++++++++++--------------- 2 files changed, 54 insertions(+), 32 deletions(-) diff --git a/src/features/score/MeiViewer.jsx b/src/features/score/MeiViewer.jsx index a394ba7a..94a50e3f 100644 --- a/src/features/score/MeiViewer.jsx +++ b/src/features/score/MeiViewer.jsx @@ -6,10 +6,21 @@ import { KeyboardCommandKey, KeyboardControlKey, KeyboardOptionKey, + PlayCircle, ZoomIn, ZoomOut, } from '@mui/icons-material' -import { Alert, Checkbox, Chip, IconButton, ListItemText, Pagination, Snackbar, Tooltip, Typography } from '@mui/material' +import { + Alert, + Checkbox, + Chip, + IconButton, + ListItemText, + Pagination, + Snackbar, + Tooltip, + Typography, +} from '@mui/material' import { Stack } from '@mui/system' import { useCallback, useEffect, useState } from 'react' import { useDispatch, useSelector } from 'react-redux' @@ -37,6 +48,7 @@ export const MeiViewer = ({ file }) => { const [scoreTitle, setScoreTitle] = useState('') const [currentPage, setCurrentPage] = useState(1) const [finalNoteId, setFinalNoteId] = useState(null) + const [showPlayer, setShowPlayer] = useState(false) const { selectedNotes, hoveredAnnotation, selectedAnnotation, isSubSelecting, scoreIri, annotatedNotes } = useSelector(state => state.globals) const color = theme.palette.primary.light @@ -183,6 +195,11 @@ export const MeiViewer = ({ file }) => { + + setShowPlayer(!showPlayer)} size="small"> + + + } @@ -262,7 +279,7 @@ export const MeiViewer = ({ file }) => { - + {showPlayer && } ) diff --git a/src/features/score/Player.jsx b/src/features/score/Player.jsx index c35d433b..5f5667c7 100644 --- a/src/features/score/Player.jsx +++ b/src/features/score/Player.jsx @@ -1,4 +1,4 @@ -import { Alert, IconButton, Slider, Snackbar, Stack, Typography } from '@mui/material' +import { Alert, Backdrop, CircularProgress, IconButton, Slider, Snackbar, Stack, Typography } from '@mui/material' import { useEffect, useRef, useState } from 'react' import { Pause, PlayArrow } from '@mui/icons-material' import { SplendidGrandPiano } from 'smplr' @@ -48,34 +48,39 @@ export const Player = ({ pageCount }) => { if (midiApi) return ( - - - - { - try { - setIsPlaying(!isPlaying) - context.resume() - midiApi.play() - } catch (error) { - midiApi.pause() - } - }} - > - {isPlaying ? : } - - {formatTime(midiApi.getSongTime() - midiApi.getSongTimeRemaining())} - - -{formatTime(midiApi.getSongTimeRemaining())} - - - + <> + + + + + + + { + try { + setIsPlaying(!isPlaying) + context.resume() + midiApi.play() + } catch (error) { + midiApi.pause() + } + }} + > + {isPlaying ? : } + + {formatTime(midiApi.getSongTime() - midiApi.getSongTimeRemaining())} + + -{formatTime(midiApi.getSongTimeRemaining())} + + + + ) }