Skip to content

Commit

Permalink
wrap each video player around a div to maintain aspect-ratio
Browse files Browse the repository at this point in the history
  • Loading branch information
ferishili committed Jun 10, 2024
1 parent a5eaccd commit a8301ed
Showing 1 changed file with 29 additions and 18 deletions.
47 changes: 29 additions & 18 deletions src/main/VideoPlayers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -399,27 +399,38 @@ export const VideoPlayer = React.forwardRef<VideoPlayerForwardRef, VideoPlayerPr
...(last) && { borderBottomRightRadius: "5px" },
});

const videoPlayerWrapperStyles = css({
height: "100%",
width: "100%",
display: "flex",
...(first && first != last) && { justifyContent: "end" },
...(last && first != last) && { justifyContent: "start" },
...(first == last) && { justifyContent: "center" },
});

const render = () => {
if (!errorState) {
return (
<ReactPlayer url={url}
css={[backgroundBoxStyle(theme), reactPlayerStyle]}
ref={ref}
width="unset"
height="unset"
playing={isPlaying}
volume={volume}
muted={!isPrimary || isMuted}
onProgress={onProgressCallback}
progressInterval={100}
onReady={onReadyCallback}
onPlay={onPlay}
onEnded={onEndedCallback}
onError={onErrorCallback}
tabIndex={-1}
config={playerConfig}
disablePictureInPicture
/>
<div css={videoPlayerWrapperStyles}>
<ReactPlayer url={url}
css={[backgroundBoxStyle(theme), reactPlayerStyle]}
ref={ref}
width="unset"
height="100%"
playing={isPlaying}
volume={volume}
muted={!isPrimary || isMuted}
onProgress={onProgressCallback}
progressInterval={100}
onReady={onReadyCallback}
onPlay={onPlay}
onEnded={onEndedCallback}
onError={onErrorCallback}
tabIndex={-1}
config={playerConfig}
disablePictureInPicture
/>
</div>
);
} else {
return (
Expand Down

0 comments on commit a8301ed

Please sign in to comment.