Skip to content

Commit bce0959

Browse files
authored
fix: compact feed videos play video when tapped (#2143)
1 parent 34c9f48 commit bce0959

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/features/media/video/Player.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export interface PlayerProps extends React.HTMLProps<HTMLElement> {
3333

3434
pauseWhenNotInView?: boolean;
3535
allowShowPlayButton?: boolean;
36+
still?: boolean;
3637

3738
ref?: React.RefObject<HTMLVideoElement>;
3839
videoRef?: React.RefObject<HTMLVideoElement | undefined>;
@@ -49,6 +50,7 @@ export default function Player({
4950
autoPlay: videoAllowedToAutoplay = true,
5051
pauseWhenNotInView = true,
5152
allowShowPlayButton = true,
53+
still = false,
5254
ref,
5355
videoRef: _videoRef,
5456
disableInlineInteraction,
@@ -122,6 +124,7 @@ export default function Player({
122124

123125
useEffect(() => {
124126
if (!videoRef.current) return;
127+
if (still) return;
125128
if (!pauseWhenNotInView) {
126129
if (autoPlay) resume();
127130

@@ -133,7 +136,13 @@ export default function Player({
133136
} else {
134137
pause();
135138
}
136-
}, [inView, pause, resume, pauseWhenNotInView, autoPlay]);
139+
}, [inView, pause, resume, pauseWhenNotInView, autoPlay, still]);
140+
141+
useEffect(() => {
142+
if (!still) return;
143+
144+
pause();
145+
}, [pause, still]);
137146

138147
useEffect(() => {
139148
function enterPip() {

src/features/post/inFeed/compact/CompactFeedPostMedia.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { ComponentProps } from "react";
22
import { PostView } from "threadiverse";
33

44
import GalleryMedia from "#/features/media/gallery/GalleryMedia";
5+
import { buildMediaId } from "#/features/media/video/VideoPortalProvider";
56

67
import usePostSrc from "../usePostSrc";
78

@@ -22,7 +23,8 @@ export default function CompactFeedPostMedia(
2223
disableInlineInteraction
2324
controls={false}
2425
volume={false}
25-
autoPlay={false}
26+
still
27+
portalWithMediaId={buildMediaId(props.post.post.ap_id)}
2628
/>
2729
);
2830
}

0 commit comments

Comments
 (0)