Skip to content

Commit

Permalink
Merge pull request #452 from Giphy/video-player-updates
Browse files Browse the repository at this point in the history
Video player updates
  • Loading branch information
giannif authored Aug 5, 2024
2 parents ef2e082 + 7eb17c5 commit e0e3717
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/silly-dots-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@giphy/react-components': minor
---

video player tweaks: hide title / fix SSR loop error
5 changes: 4 additions & 1 deletion packages/react-components/src/components/video/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ type Props = {
controls?: boolean
// if controls is true, hides progress bar
hideProgressBar?: boolean
// if controls is true, hides the title
hideTitle?: boolean
// if controls is true, hides mute
hideMute?: boolean
// hide attribution
Expand Down Expand Up @@ -112,6 +114,7 @@ const VideoPlayer = (props: ComponentProps<typeof VideoWrapper>) => {
hideMute,
hideAttribution,
hideProgressBar,
hideTitle,
className,
persistentControls,
gif,
Expand Down Expand Up @@ -193,7 +196,7 @@ const VideoPlayer = (props: ComponentProps<typeof VideoWrapper>) => {
{showControls && <Gradient $isLargePlayer={isLargePlayer} />}
<Controls $isHovered={showControls}>
<TitleContainer>
{isLargePlayer && (
{!hideTitle && isLargePlayer && (
<Title
onClick={(e) => {
e.preventDefault()
Expand Down
8 changes: 4 additions & 4 deletions packages/react-components/src/components/video/video.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,15 @@ const Video = ({
}
}, [onWaiting])
const _onEnded = useCallback(() => {
// helps prevent two ended events when changing media
if (!hasPlayingFired.current) {
return
}
if (loop && videoEl.current) {
videoEl.current.play()
}
onLoop?.(loopNumber.current)
loopNumber.current = loopNumber.current + 1
// helps prevent two ended events when changing media
if (!hasPlayingFired.current) {
return
}
onEnded?.()
}, [onEnded, loop, onLoop])
const _onEndFullscreen = useCallback(() => onEndFullscreen?.(), [onEndFullscreen])
Expand Down

0 comments on commit e0e3717

Please sign in to comment.