Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New-player-with-old-skin #262

Merged
merged 6 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@appquality/unguess-design-system",
"version": "3.1.41-player",
"version": "3.1.44",
"description": "",
"main": "build/index.js",
"types": "build/index.d.ts",
Expand Down
18 changes: 17 additions & 1 deletion src/stories/player/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,29 @@ const Player = forwardRef<HTMLVideoElement, PlayerArgs>((props, forwardRef) => {

const PlayerCore = forwardRef<HTMLVideoElement, PlayerArgs>(
(props, forwardRef) => {
const { context, togglePlay } = useVideoContext();
const { context, togglePlay, setIsPlaying } = useVideoContext();
const videoRef = context.player?.ref.current;
const isLoaded = !!videoRef;
const containerRef = useRef<HTMLDivElement>(null);

useImperativeHandle(forwardRef, () => videoRef as HTMLVideoElement);

useEffect(() => {
if (videoRef) {
videoRef.addEventListener("pause", () => {
setIsPlaying(false);
});
}

return () => {
if (videoRef) {
videoRef.removeEventListener("pause", () => {
setIsPlaying(false);
});
}
};
}, [videoRef]);

return (
<Container
isLoaded={isLoaded}
Expand Down
22 changes: 21 additions & 1 deletion src/stories/player/parts/fullScreenButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,22 @@ export const FullScreenButton = ({
return false;
}, [ref]);

useEffect(() => {
if (ref) {
ref.addEventListener("fullscreenchange", () => {
setFullScreen(!!document.fullscreenElement);
});
}

return () => {
if (ref) {
ref.removeEventListener("fullscreenchange", () => {
setFullScreen(!!document.fullscreenElement);
});
}
};
}, [ref]);

return (
<IconButton
isBright
Expand All @@ -78,7 +94,11 @@ export const FullScreenButton = ({
}}
disabled={!canGoFullScreen()}
>
{document.fullscreenElement || isFullScreen ? <FullScreenExit /> : <FullScreenEnter />}
{document.fullscreenElement || isFullScreen ? (
<FullScreenExit />
) : (
<FullScreenEnter />
)}
</IconButton>
);
};
36 changes: 18 additions & 18 deletions src/stories/slider/index.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,24 @@ const TextContainer = styled.div`

const Template: Story<SliderStoryArg> = ({ items, ...args }) => {
return (
<Slider {...args}>
{items.map((item) => (
<div>
<Slider.Slide>
{item.imageUrl && <img src={item.imageUrl} />}
{item.videoUrl && (
<Player url={item.videoUrl} />
)}
{item.headerTitle && item.content && (
<TextContainer>
<XL>{item.headerTitle}</XL>
<MD>{item.content}</MD>
</TextContainer>
)}
</Slider.Slide>
</div>
))}
</Slider>
<div style={{ height: "80vh" }}>
<Slider {...args}>
{items.map((item) => (
<div>
<Slider.Slide>
{item.imageUrl && <img src={item.imageUrl} />}
{item.videoUrl && <Player url={item.videoUrl} />}
{item.headerTitle && item.content && (
<TextContainer>
<XL>{item.headerTitle}</XL>
<MD>{item.content}</MD>
</TextContainer>
)}
</Slider.Slide>
</div>
))}
</Slider>
</div>
);
};

Expand Down
Loading