2026-06-17 23:47:14 +04:00
|
|
|
'use client'
|
|
|
|
|
|
2026-06-18 00:08:24 +04:00
|
|
|
import {useState, useEffect, forwardRef} from 'react'
|
2026-06-17 23:47:14 +04:00
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
|
import Fab from '@mui/material/Fab'
|
|
|
|
|
import Dialog from '@mui/material/Dialog'
|
|
|
|
|
import Slide from '@mui/material/Slide'
|
|
|
|
|
import Box from '@mui/material/Box'
|
2026-06-18 00:08:24 +04:00
|
|
|
import Skeleton from '@mui/material/Skeleton'
|
2026-06-17 23:47:14 +04:00
|
|
|
import IconButton from '@mui/material/IconButton'
|
|
|
|
|
import Typography from '@mui/material/Typography'
|
|
|
|
|
import Tooltip from '@mui/material/Tooltip'
|
|
|
|
|
import useMediaQuery from '@mui/material/useMediaQuery'
|
2026-06-18 00:08:24 +04:00
|
|
|
import {useTheme, keyframes} from '@mui/material/styles'
|
2026-06-18 00:14:34 +04:00
|
|
|
import MicIcon from '@mui/icons-material/Mic'
|
|
|
|
|
import CloseIcon from '@mui/icons-material/Close'
|
2026-06-18 00:08:24 +04:00
|
|
|
|
|
|
|
|
const pulse = keyframes`
|
|
|
|
|
0%, 100% { opacity: 0.18; transform: scale(1); }
|
|
|
|
|
50% { opacity: 0.55; transform: scale(1.2); }
|
|
|
|
|
`
|
2026-06-17 23:47:14 +04:00
|
|
|
|
|
|
|
|
const SlideUp = forwardRef(function SlideUp(props, ref) {
|
|
|
|
|
return <Slide direction='up' ref={ref} {...props} />
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
function toEmbedUrl(url) {
|
|
|
|
|
try {
|
|
|
|
|
const u = new URL(url)
|
|
|
|
|
const match = u.pathname.match(/\/(?:videos\/watch|w)\/([^/?#]+)/)
|
|
|
|
|
if (match) {
|
|
|
|
|
return `${u.origin}/videos/embed/${match[1]}?title=0&warningTitle=0&peertubeLink=0&controlBar=1`
|
|
|
|
|
}
|
|
|
|
|
return url
|
|
|
|
|
} catch {
|
|
|
|
|
return url
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-18 00:33:28 +04:00
|
|
|
export default function KaraokeModal({url, desktopUrl, titre, artistes}) {
|
2026-06-17 23:47:14 +04:00
|
|
|
const [open, setOpen] = useState(false)
|
2026-06-18 00:08:24 +04:00
|
|
|
const [loaded, setLoaded] = useState(false)
|
2026-06-17 23:47:14 +04:00
|
|
|
const theme = useTheme()
|
|
|
|
|
const isMobile = useMediaQuery(theme.breakpoints.down('sm'))
|
2026-06-18 00:33:28 +04:00
|
|
|
const activeUrl = (!isMobile && desktopUrl) ? desktopUrl : url
|
2026-06-17 23:47:14 +04:00
|
|
|
|
2026-06-18 00:08:24 +04:00
|
|
|
useEffect(() => {
|
|
|
|
|
if (!open) setLoaded(false)
|
|
|
|
|
}, [open])
|
|
|
|
|
|
2026-06-17 23:47:14 +04:00
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<Tooltip title='Karaoké' placement='left'>
|
|
|
|
|
<Fab
|
|
|
|
|
color='primary'
|
|
|
|
|
size={isMobile ? 'medium' : 'large'}
|
|
|
|
|
aria-label='karaoké'
|
|
|
|
|
onClick={() => setOpen(true)}
|
|
|
|
|
sx={{
|
|
|
|
|
position: 'fixed',
|
|
|
|
|
bottom: {xs: 24, sm: 32},
|
|
|
|
|
right: {xs: 24, sm: 32},
|
2026-06-18 00:33:28 +04:00
|
|
|
zIndex: 1050,
|
2026-06-17 23:47:14 +04:00
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<MicIcon />
|
|
|
|
|
</Fab>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
|
|
|
|
|
<Dialog
|
|
|
|
|
open={open}
|
|
|
|
|
onClose={() => setOpen(false)}
|
2026-06-18 00:08:24 +04:00
|
|
|
slots={{transition: SlideUp}}
|
2026-06-17 23:47:14 +04:00
|
|
|
maxWidth={false}
|
2026-06-18 00:08:24 +04:00
|
|
|
sx={{
|
|
|
|
|
'& .MuiDialog-container': {
|
|
|
|
|
alignItems: {xs: 'flex-end', sm: 'center'},
|
|
|
|
|
}
|
2026-06-17 23:47:14 +04:00
|
|
|
}}
|
2026-06-18 00:08:24 +04:00
|
|
|
slotProps={{
|
|
|
|
|
backdrop: {sx: {backdropFilter: 'blur(6px)', bgcolor: 'rgba(0,0,0,0.85)'}},
|
|
|
|
|
paper: {
|
|
|
|
|
sx: {
|
|
|
|
|
bgcolor: '#000',
|
|
|
|
|
overflow: 'hidden',
|
|
|
|
|
...(isMobile ? {
|
|
|
|
|
width: '100vw',
|
|
|
|
|
height: '100dvh',
|
|
|
|
|
maxWidth: 'none',
|
|
|
|
|
maxHeight: 'none',
|
|
|
|
|
m: 0,
|
|
|
|
|
borderRadius: 0,
|
|
|
|
|
boxShadow: 'none',
|
|
|
|
|
} : {
|
2026-06-18 00:33:28 +04:00
|
|
|
width: 'calc(80vh * 16 / 9)',
|
|
|
|
|
height: '80vh',
|
2026-06-18 00:08:24 +04:00
|
|
|
maxWidth: 'none',
|
|
|
|
|
maxHeight: 'none',
|
|
|
|
|
borderRadius: '16px',
|
|
|
|
|
boxShadow: '0 24px 64px rgba(0,0,0,0.7)',
|
|
|
|
|
})
|
|
|
|
|
}
|
2026-06-17 23:47:14 +04:00
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
>
|
2026-06-18 00:08:24 +04:00
|
|
|
{/* Header superposé en gradient */}
|
2026-06-17 23:47:14 +04:00
|
|
|
<Box sx={{
|
|
|
|
|
position: 'absolute',
|
|
|
|
|
top: 0,
|
|
|
|
|
left: 0,
|
|
|
|
|
right: 0,
|
2026-06-18 00:08:24 +04:00
|
|
|
zIndex: 2,
|
2026-06-17 23:47:14 +04:00
|
|
|
px: 2,
|
2026-06-18 00:08:24 +04:00
|
|
|
pt: 2,
|
|
|
|
|
pb: 4,
|
|
|
|
|
background: 'linear-gradient(to bottom, rgba(0,0,0,0.8) 0%, transparent 100%)',
|
2026-06-17 23:47:14 +04:00
|
|
|
display: 'flex',
|
|
|
|
|
alignItems: 'flex-start',
|
|
|
|
|
justifyContent: 'space-between',
|
2026-06-18 00:08:24 +04:00
|
|
|
pointerEvents: 'none',
|
2026-06-17 23:47:14 +04:00
|
|
|
}}>
|
2026-06-18 00:08:24 +04:00
|
|
|
<Box sx={{pointerEvents: 'none'}}>
|
2026-06-17 23:47:14 +04:00
|
|
|
{titre && (
|
2026-06-18 00:08:24 +04:00
|
|
|
<Typography variant='subtitle1' sx={{color: '#fff', fontWeight: 700, lineHeight: 1.2, textShadow: '0 1px 4px rgba(0,0,0,0.5)'}}>
|
2026-06-17 23:47:14 +04:00
|
|
|
{titre}
|
|
|
|
|
</Typography>
|
|
|
|
|
)}
|
|
|
|
|
{artistes?.length > 0 && (
|
2026-06-18 00:08:24 +04:00
|
|
|
<Typography variant='caption' sx={{color: 'rgba(255,255,255,0.65)', textShadow: '0 1px 4px rgba(0,0,0,0.5)'}}>
|
2026-06-17 23:47:14 +04:00
|
|
|
{artistes.map(a => a.alias).join(', ')}
|
|
|
|
|
</Typography>
|
|
|
|
|
)}
|
|
|
|
|
</Box>
|
|
|
|
|
<IconButton
|
|
|
|
|
size='small'
|
|
|
|
|
onClick={() => setOpen(false)}
|
|
|
|
|
aria-label='fermer'
|
|
|
|
|
sx={{
|
2026-06-18 00:08:24 +04:00
|
|
|
pointerEvents: 'auto',
|
2026-06-17 23:47:14 +04:00
|
|
|
color: '#fff',
|
|
|
|
|
bgcolor: 'rgba(255,255,255,0.15)',
|
2026-06-18 00:08:24 +04:00
|
|
|
backdropFilter: 'blur(8px)',
|
|
|
|
|
border: '1px solid rgba(255,255,255,0.12)',
|
2026-06-17 23:47:14 +04:00
|
|
|
'&:hover': {bgcolor: 'rgba(255,255,255,0.25)'},
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<CloseIcon fontSize='small' />
|
|
|
|
|
</IconButton>
|
|
|
|
|
</Box>
|
|
|
|
|
|
|
|
|
|
{open && (
|
2026-06-18 00:08:24 +04:00
|
|
|
<Box sx={{position: 'absolute', inset: 0, overflow: 'hidden'}}>
|
|
|
|
|
{!loaded && (
|
|
|
|
|
<>
|
|
|
|
|
<Skeleton
|
|
|
|
|
variant='rectangular'
|
|
|
|
|
animation='wave'
|
|
|
|
|
sx={{position: 'absolute', inset: 0, bgcolor: 'rgba(255,255,255,0.06)', transform: 'none'}}
|
|
|
|
|
/>
|
|
|
|
|
<Box sx={{
|
|
|
|
|
position: 'absolute',
|
|
|
|
|
inset: 0,
|
|
|
|
|
zIndex: 1,
|
|
|
|
|
display: 'flex',
|
|
|
|
|
flexDirection: 'column',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
justifyContent: 'center',
|
|
|
|
|
gap: 1.5,
|
|
|
|
|
}}>
|
|
|
|
|
<MicIcon sx={{fontSize: 44, color: 'rgba(255,255,255,0.55)', animation: `${pulse} 1.6s ease-in-out infinite`}} />
|
|
|
|
|
<Typography
|
|
|
|
|
variant='caption'
|
|
|
|
|
sx={{color: 'rgba(255,255,255,0.35)', letterSpacing: '0.15em', textTransform: 'uppercase'}}
|
|
|
|
|
>
|
|
|
|
|
Chargement…
|
|
|
|
|
</Typography>
|
|
|
|
|
</Box>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
|
2026-06-18 00:33:28 +04:00
|
|
|
{isMobile ? (
|
|
|
|
|
/* Vidéo verticale : scale le player 16:9 à la hauteur du portrait et croppe les côtés */
|
|
|
|
|
<Box sx={{
|
|
|
|
|
position: 'absolute',
|
|
|
|
|
top: 0,
|
|
|
|
|
left: '50%',
|
|
|
|
|
transform: 'translateX(-50%)',
|
|
|
|
|
height: '100%',
|
|
|
|
|
aspectRatio: '16 / 9',
|
|
|
|
|
}}>
|
|
|
|
|
<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>
|
|
|
|
|
) : (
|
|
|
|
|
/* Vidéo 16:9 desktop : player remplit exactement le dialog paysage */
|
2026-06-18 00:08:24 +04:00
|
|
|
<iframe
|
2026-06-18 00:33:28 +04:00
|
|
|
src={toEmbedUrl(activeUrl)}
|
2026-06-18 00:08:24 +04:00
|
|
|
onLoad={() => setLoaded(true)}
|
2026-06-18 00:33:28 +04:00
|
|
|
style={{width: '100%', height: '100%', border: 'none', display: 'block', opacity: loaded ? 1 : 0, transition: 'opacity 0.4s ease'}}
|
2026-06-18 00:08:24 +04:00
|
|
|
allowFullScreen
|
|
|
|
|
allow='autoplay; fullscreen'
|
|
|
|
|
sandbox='allow-same-origin allow-scripts allow-popups allow-forms'
|
|
|
|
|
title='Karaoké'
|
|
|
|
|
/>
|
2026-06-18 00:33:28 +04:00
|
|
|
)}
|
2026-06-18 00:08:24 +04:00
|
|
|
</Box>
|
2026-06-17 23:47:14 +04:00
|
|
|
)}
|
|
|
|
|
</Dialog>
|
|
|
|
|
</>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
KaraokeModal.propTypes = {
|
|
|
|
|
url: PropTypes.string.isRequired,
|
2026-06-18 00:33:28 +04:00
|
|
|
desktopUrl: PropTypes.string,
|
2026-06-17 23:47:14 +04:00
|
|
|
titre: PropTypes.string,
|
|
|
|
|
artistes: PropTypes.array,
|
|
|
|
|
}
|