feat: add desktopUrl
This commit is contained in:
@@ -37,11 +37,12 @@ function toEmbedUrl(url) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function KaraokeModal({url, titre, artistes}) {
|
export default function KaraokeModal({url, desktopUrl, titre, artistes}) {
|
||||||
const [open, setOpen] = useState(false)
|
const [open, setOpen] = useState(false)
|
||||||
const [loaded, setLoaded] = useState(false)
|
const [loaded, setLoaded] = useState(false)
|
||||||
const theme = useTheme()
|
const theme = useTheme()
|
||||||
const isMobile = useMediaQuery(theme.breakpoints.down('sm'))
|
const isMobile = useMediaQuery(theme.breakpoints.down('sm'))
|
||||||
|
const activeUrl = (!isMobile && desktopUrl) ? desktopUrl : url
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!open) setLoaded(false)
|
if (!open) setLoaded(false)
|
||||||
@@ -59,7 +60,7 @@ export default function KaraokeModal({url, titre, artistes}) {
|
|||||||
position: 'fixed',
|
position: 'fixed',
|
||||||
bottom: {xs: 24, sm: 32},
|
bottom: {xs: 24, sm: 32},
|
||||||
right: {xs: 24, sm: 32},
|
right: {xs: 24, sm: 32},
|
||||||
zIndex: 10,
|
zIndex: 1050,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<MicIcon />
|
<MicIcon />
|
||||||
@@ -91,8 +92,8 @@ export default function KaraokeModal({url, titre, artistes}) {
|
|||||||
borderRadius: 0,
|
borderRadius: 0,
|
||||||
boxShadow: 'none',
|
boxShadow: 'none',
|
||||||
} : {
|
} : {
|
||||||
width: 'calc(88vh * 9 / 16)',
|
width: 'calc(80vh * 16 / 9)',
|
||||||
height: '88vh',
|
height: '80vh',
|
||||||
maxWidth: 'none',
|
maxWidth: 'none',
|
||||||
maxHeight: 'none',
|
maxHeight: 'none',
|
||||||
borderRadius: '16px',
|
borderRadius: '16px',
|
||||||
@@ -149,7 +150,6 @@ export default function KaraokeModal({url, titre, artistes}) {
|
|||||||
|
|
||||||
{open && (
|
{open && (
|
||||||
<Box sx={{position: 'absolute', inset: 0, overflow: 'hidden'}}>
|
<Box sx={{position: 'absolute', inset: 0, overflow: 'hidden'}}>
|
||||||
{/* Skeleton affiché pendant le chargement */}
|
|
||||||
{!loaded && (
|
{!loaded && (
|
||||||
<>
|
<>
|
||||||
<Skeleton
|
<Skeleton
|
||||||
@@ -178,12 +178,8 @@ export default function KaraokeModal({url, titre, artistes}) {
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/*
|
{isMobile ? (
|
||||||
Le player PeerTube impose un ratio 16:9 en interne.
|
/* Vidéo verticale : scale le player 16:9 à la hauteur du portrait et croppe les côtés */
|
||||||
On étire l'iframe en 16:9 sur toute la hauteur du conteneur portrait,
|
|
||||||
on le centre horizontalement, et overflow:hidden croppe les côtés.
|
|
||||||
Le centre visible correspond exactement à la zone vidéo verticale.
|
|
||||||
*/}
|
|
||||||
<Box sx={{
|
<Box sx={{
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
top: 0,
|
top: 0,
|
||||||
@@ -193,22 +189,27 @@ export default function KaraokeModal({url, titre, artistes}) {
|
|||||||
aspectRatio: '16 / 9',
|
aspectRatio: '16 / 9',
|
||||||
}}>
|
}}>
|
||||||
<iframe
|
<iframe
|
||||||
src={toEmbedUrl(url)}
|
src={toEmbedUrl(activeUrl)}
|
||||||
onLoad={() => setLoaded(true)}
|
onLoad={() => setLoaded(true)}
|
||||||
style={{
|
style={{width: '100%', height: '100%', border: 'none', display: 'block', opacity: loaded ? 1 : 0, transition: 'opacity 0.4s ease'}}
|
||||||
width: '100%',
|
|
||||||
height: '100%',
|
|
||||||
border: 'none',
|
|
||||||
display: 'block',
|
|
||||||
opacity: loaded ? 1 : 0,
|
|
||||||
transition: 'opacity 0.4s ease',
|
|
||||||
}}
|
|
||||||
allowFullScreen
|
allowFullScreen
|
||||||
allow='autoplay; fullscreen'
|
allow='autoplay; fullscreen'
|
||||||
sandbox='allow-same-origin allow-scripts allow-popups allow-forms'
|
sandbox='allow-same-origin allow-scripts allow-popups allow-forms'
|
||||||
title='Karaoké'
|
title='Karaoké'
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
|
) : (
|
||||||
|
/* Vidéo 16:9 desktop : player remplit exactement le dialog paysage */
|
||||||
|
<iframe
|
||||||
|
src={toEmbedUrl(activeUrl)}
|
||||||
|
onLoad={() => setLoaded(true)}
|
||||||
|
style={{width: '100%', height: '100%', border: 'none', display: 'block', opacity: loaded ? 1 : 0, transition: 'opacity 0.4s ease'}}
|
||||||
|
allowFullScreen
|
||||||
|
allow='autoplay; fullscreen'
|
||||||
|
sandbox='allow-same-origin allow-scripts allow-popups allow-forms'
|
||||||
|
title='Karaoké'
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
</Dialog>
|
</Dialog>
|
||||||
@@ -218,6 +219,7 @@ export default function KaraokeModal({url, titre, artistes}) {
|
|||||||
|
|
||||||
KaraokeModal.propTypes = {
|
KaraokeModal.propTypes = {
|
||||||
url: PropTypes.string.isRequired,
|
url: PropTypes.string.isRequired,
|
||||||
|
desktopUrl: PropTypes.string,
|
||||||
titre: PropTypes.string,
|
titre: PropTypes.string,
|
||||||
artistes: PropTypes.array,
|
artistes: PropTypes.array,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ export default function TeksDrawer({paroles}) {
|
|||||||
</Drawer>
|
</Drawer>
|
||||||
</Box>
|
</Box>
|
||||||
{parole?.karaokeUrl && (
|
{parole?.karaokeUrl && (
|
||||||
<KaraokeModal url={parole.karaokeUrl} titre={parole.titre} artistes={parole.artistes} />
|
<KaraokeModal url={parole.karaokeUrl} desktopUrl={parole.karaokeDesktopUrl} titre={parole.titre} artistes={parole.artistes} />
|
||||||
)}
|
)}
|
||||||
{success && (
|
{success && (
|
||||||
<Snackbar open={open} autoHideDuration={3000} onClose={handleClose}>
|
<Snackbar open={open} autoHideDuration={3000} onClose={handleClose}>
|
||||||
|
|||||||
Reference in New Issue
Block a user