Skip to content
This repository has been archived by the owner on Dec 24, 2024. It is now read-only.

Commit

Permalink
fix(player): use new slot to place theater icon properly
Browse files Browse the repository at this point in the history
  • Loading branch information
Zibbp committed Feb 18, 2024
1 parent b5f5587 commit 25366a1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 46 deletions.
7 changes: 0 additions & 7 deletions src/components/Vod/TheaterModeIcon.module.css
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
.theaterIcon {
position: absolute;
top: 0;
right: 0;
z-index: 100;
padding: 0.5rem;
cursor: pointer;
color: #f5f5f5;
transition: all 0.2s ease-in-out;


}
.customFullScreenButton {
color: #f5f5f5;
Expand Down
2 changes: 1 addition & 1 deletion src/components/Vod/TheaterModeIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const TheaterModeIcon = () => {
onTouchStart={toggleTheaterMode}
className={classes.customFullScreenButton}
>
<IconMaximize size="1.8rem" />
<IconMaximize size="1.7rem" />
</ActionIcon>
</Tooltip>
</div>
Expand Down
45 changes: 7 additions & 38 deletions src/components/Vod/VideoPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,31 +41,16 @@ const NewVideoPlayer = ({ vod }: any) => {
const [videoPoster, setVideoPoster] = useState<string>("");
const [videoTitle, setVideoTitle] = useState<string>("");
const startedPlayback = useRef(false);
const [playerIsHovered, setPlayerIsHovered] = useState(true);
const [isFullscreen, setIsFullscreen] = useState(false);

const searchParams = useSearchParams()

const handleHover = () => {
setPlayerIsHovered(true);
};

const handleMouseLeave = () => {
setPlayerIsHovered(false);
};

const handleTouch = () => {
setPlayerIsHovered(!playerIsHovered);
};

useEffect(() => {
eventBus.on("theaterMode", (data) => {
setIsFullscreen(data);
});
}, []);



// Fetch playback data
const { data } = useQuery({
refetchOnWindowFocus: false,
Expand Down Expand Up @@ -172,20 +157,6 @@ const NewVideoPlayer = ({ vod }: any) => {
player.current!.currentTime = parseInt(time);
}

// const mediaFullscreenButton = document.querySelector("#media-menu-2");
// console.log(mediaFullscreenButton)
// const buttonContainer = document.createElement("div");

// if (mediaFullscreenButton) {
// mediaFullscreenButton.parentNode.insertBefore(
// buttonContainer,
// mediaFullscreenButton.nextSibling
// );
// // Render the button component inside the container
// ReactDOM.render(<TheaterModeIcon />, buttonContainer);
// }


}, [data, player]);


Expand Down Expand Up @@ -262,26 +233,24 @@ const NewVideoPlayer = ({ vod }: any) => {
src={videoSource}
aspect-ratio={16 / 9}
ref={player}
crossorigin
onMouseEnter={handleHover}
onMouseLeave={handleMouseLeave}
onTouchStart={handleTouch}
playsinline
crossOrigin={true}
playsInline={true}
>

<MediaProvider >
<Poster className="vds-poster" src={videoPoster} alt={vod.title} />
{playerIsHovered && (
<TheaterModeIcon />
)}
<Track
src={`${publicRuntimeConfig.API_URL}/api/v1/chapter/video/${vod.id}/webvtt`}
kind="chapters"
default={true}
/>
</MediaProvider>

<DefaultVideoLayout icons={defaultLayoutIcons} > </DefaultVideoLayout>
<DefaultVideoLayout icons={defaultLayoutIcons} noScrubGesture={false}
slots={{
beforeFullscreenButton: <TheaterModeIcon />,
}}
/>
</MediaPlayer>
</div>
);
Expand Down

0 comments on commit 25366a1

Please sign in to comment.