Improve src parameter

This commit is contained in:
Nicola Benaglia 2025-06-07 00:33:46 +02:00
parent 256d565663
commit f9a51333d6

View File

@ -57,27 +57,27 @@ const ControlsContainer = styled(Box)`
`; `;
interface VideoPlayerProps { interface VideoPlayerProps {
src?: string;
poster?: string;
name?: string;
identifier?: string;
service?: string;
autoplay?: boolean; autoplay?: boolean;
from?: string | null;
customStyle?: any; customStyle?: any;
from?: string | null;
identifier?: string;
name?: string;
poster?: string;
service?: string;
src?: string | null;
user?: string; user?: string;
} }
// TODO translate and theme (optional) // TODO translate and theme (optional)
export const VideoPlayer: FC<VideoPlayerProps> = ({ export const VideoPlayer: FC<VideoPlayerProps> = ({
poster,
name,
identifier,
service,
autoplay = true, autoplay = true,
from = null,
customStyle = {}, customStyle = {},
from = null,
identifier,
name,
node, node,
poster,
service,
}) => { }) => {
const keyIdentifier = useMemo(() => { const keyIdentifier = useMemo(() => {
if (name && identifier && service) { if (name && identifier && service) {
@ -549,22 +549,22 @@ export const VideoPlayer: FC<VideoPlayerProps> = ({
)} )}
{((!src && !isLoading) || !startPlay) && ( {((!src && !isLoading) || !startPlay) && (
<Box <Box
position="absolute" alignItems="center"
top={0} bgcolor="rgba(0, 0, 0, 0.6)"
left={0}
right={0}
bottom={0} bottom={0}
display="flex" display="flex"
justifyContent="center" justifyContent="center"
alignItems="center" left={0}
zIndex={500}
bgcolor="rgba(0, 0, 0, 0.6)"
onClick={() => { onClick={() => {
togglePlay(); togglePlay();
}} }}
position="absolute"
right={0}
sx={{ sx={{
cursor: 'pointer', cursor: 'pointer',
}} }}
top={0}
zIndex={500}
> >
<PlayArrow <PlayArrow
sx={{ sx={{
@ -587,7 +587,9 @@ export const VideoPlayer: FC<VideoPlayerProps> = ({
<VideoElement <VideoElement
id={identifier} id={identifier}
ref={videoRef} ref={videoRef}
src={!startPlay ? '' : resourceStatus?.status === 'READY' ? src : ''} src={
!startPlay ? null : resourceStatus?.status === 'READY' ? src : null
}
poster={!startPlay ? poster : ''} poster={!startPlay ? poster : ''}
onTimeUpdate={updateProgress} onTimeUpdate={updateProgress}
autoPlay={autoplay} autoPlay={autoplay}