Skip to content

Commit

Permalink
fix(inlineplayer): display correct video title after play next clicked
Browse files Browse the repository at this point in the history
  • Loading branch information
olga-jwp committed Dec 22, 2022
1 parent 02a944c commit bffc1d9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/components/Player/Player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type Props = {
onBeforePlay?: () => void;
onFirstFrame?: () => void;
onRemove?: () => void;
onNext?: () => void;
onPlaylistItem?: () => void;
onPlaylistItemCallback?: (item: PlaylistItem) => Promise<undefined | PlaylistItem>;
startTime?: number;
Expand All @@ -43,6 +44,7 @@ const Player: React.FC<Props> = ({
onRemove,
onPlaylistItem,
onPlaylistItemCallback,
onNext,
feedId,
startTime = 0,
autostart,
Expand All @@ -65,6 +67,7 @@ const Player: React.FC<Props> = ({
const handleRemove = useEventCallback(onRemove);
const handlePlaylistItem = useEventCallback(onPlaylistItem);
const handlePlaylistItemCallback = useEventCallback(onPlaylistItemCallback);
const handleNextClick = useEventCallback(onNext);
const handleReady = useEventCallback(() => onReady && onReady(playerRef.current));

const attachEvents = useCallback(() => {
Expand All @@ -78,6 +81,7 @@ const Player: React.FC<Props> = ({
playerRef.current?.on('firstFrame', handleFirstFrame);
playerRef.current?.on('remove', handleRemove);
playerRef.current?.on('playlistItem', handlePlaylistItem);
playerRef.current?.on('nextClick', handleNextClick);
playerRef.current?.setPlaylistItemCallback(handlePlaylistItemCallback);
}, [
handleReady,
Expand All @@ -90,6 +94,7 @@ const Player: React.FC<Props> = ({
handleFirstFrame,
handleRemove,
handlePlaylistItem,
handleNextClick,
handlePlaylistItemCallback,
]);

Expand Down
7 changes: 7 additions & 0 deletions src/containers/Cinema/Cinema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type Props = {
onPause?: () => void;
onComplete?: () => void;
onClose?: () => void;
onNext?: () => void;
feedId?: string;
title: string;
primaryMetadata: React.ReactNode;
Expand All @@ -35,6 +36,7 @@ const Cinema: React.FC<Props> = ({
onPause,
onComplete,
onClose,
onNext,
feedId,
liveStartDateTime,
liveEndDateTime,
Expand All @@ -60,6 +62,10 @@ const Cinema: React.FC<Props> = ({
onComplete && onComplete();
}, [onComplete]);

const handleNext = useCallback(() => {
onNext && onNext();
}, [onNext]);

const handleUserActive = useCallback(() => setUserActive(true), []);
const handleUserInactive = useCallback(() => setUserActive(false), []);

Expand Down Expand Up @@ -87,6 +93,7 @@ const Cinema: React.FC<Props> = ({
onComplete={handleComplete}
onUserActive={handleUserActive}
onUserInActive={handleUserInactive}
onNext={handleNext}
liveEndDateTime={liveEndDateTime}
liveFromBeginning={liveFromBeginning}
liveStartDateTime={liveStartDateTime}
Expand Down
3 changes: 3 additions & 0 deletions src/containers/PlayerContainer/PlayerContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type Props = {
onClose?: () => void;
onUserActive?: () => void;
onUserInActive?: () => void;
onNext?: () => void;
feedId?: string;
liveStartDateTime?: string | null;
liveEndDateTime?: string | null;
Expand All @@ -33,6 +34,7 @@ const PlayerContainer: React.FC<Props> = ({
onComplete,
onUserActive,
onUserInActive,
onNext,
liveEndDateTime,
liveFromBeginning,
liveStartDateTime,
Expand Down Expand Up @@ -125,6 +127,7 @@ const PlayerContainer: React.FC<Props> = ({
onRemove={handleRemove}
onUserActive={onUserActive}
onUserInActive={onUserInActive}
onNext={onNext}
onPlaylistItemCallback={handlePlaylistItemCallback}
startTime={startTime}
autostart={autostart}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ const MediaMovie: ScreenComponent<PlaylistItem> = ({ data, isLoading }) => {
primaryMetadata={primaryMetadata}
onComplete={handleComplete}
feedId={feedId ?? undefined}
onNext={handleComplete}
/>
)
}
Expand Down

0 comments on commit bffc1d9

Please sign in to comment.