Skip to content

Commit ba29d43

Browse files
authored
Merge pull request #886 from AppQuality/UTT-75-make-seek-play-a-play-button-again
Refactor Player and Transcript components
2 parents 834fc43 + a89b6ec commit ba29d43

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/pages/Video/components/Player.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const CorePlayer = ({ video }: { video: GetVideosByVidApiResponse }) => {
5252
const [postVideoByVidObservations] = usePostVideosByVidObservationsMutation();
5353
const [patchObservation] = usePatchVideosByVidObservationsAndOidMutation();
5454
const [start, setStart] = useState<number | undefined>(undefined);
55-
const { context } = usePlayerContext();
55+
const { context, setIsPlaying } = usePlayerContext();
5656
const { currentTime } = context.player || { currentTime: 0 };
5757
const { addToast } = useToast();
5858

@@ -124,9 +124,14 @@ const CorePlayer = ({ video }: { video: GetVideosByVidApiResponse }) => {
124124
);
125125

126126
const seekPlayer = useCallback(
127-
(time: number) => {
127+
(time: number, forcePlay?: boolean) => {
128128
if (videoRef && videoRef.current) {
129129
videoRef.current.currentTime = time;
130+
131+
if (forcePlay) {
132+
setIsPlaying(true);
133+
videoRef.current.play();
134+
}
130135
}
131136
},
132137
[videoRef]

src/pages/Video/components/Transcript.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ const Transcript = ({
7474
}: {
7575
currentTime: number;
7676
isSearchable: boolean;
77-
setCurrentTime: (time: number) => void;
77+
setCurrentTime: (time: number, forcePlay?: boolean) => void;
7878
}) => {
7979
const { t } = useTranslation();
8080
const { videoId } = useParams();
@@ -189,7 +189,7 @@ const Transcript = ({
189189
start={p.start}
190190
end={p.end}
191191
speakerIndex={p.speaker || 0}
192-
setCurrentTime={setCurrentTime}
192+
setCurrentTime={(time) => setCurrentTime(time, true)}
193193
>
194194
{p.words.map((item, index) => (
195195
<Highlight.Word

0 commit comments

Comments
 (0)