Skip to content

Commit

Permalink
feat/add-caption-control 👉 fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
LunatiqueCoder committed Jan 19, 2024
1 parent ad8492e commit fde8853
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
10 changes: 6 additions & 4 deletions packages/media-console/src/VideoPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ const AnimatedVideoPlayer = (
const [currentTime, setCurrentTime] = useState(0);
const [error, setError] = useState(false);
const [duration, setDuration] = useState(0);
const [isCaption, setIsCaption] = useState<boolean>(false);
const [isCaptionEnabled, setIsCaptionEnabled] = useState<boolean>(false);

const videoRef = props.videoRef || _videoRef;

const toggleFullscreen = () => setIsFullscreen((prevState) => !prevState);
const toggleCaption = () => setIsCaption((prevState) => !prevState);
const toggleCaption = () => setIsCaptionEnabled((prevState) => !prevState);
const toggleControls = () =>
setShowControls((prevState) => alwaysShowControls || !prevState);
const toggleTimer = () => setShowTimeRemaining((prevState) => !prevState);
Expand Down Expand Up @@ -407,7 +407,9 @@ const AnimatedVideoPlayer = (
<Video
{...props}
{...events}
selectedTextTrack={isCaption ? props.selectedTextTrack : undefined}
selectedTextTrack={
isCaptionEnabled ? props.selectedTextTrack : undefined
}
ref={videoRef || _videoRef}
resizeMode={_resizeMode}
volume={_volume}
Expand Down Expand Up @@ -469,7 +471,7 @@ const AnimatedVideoPlayer = (
seekerPosition={seekerPosition}
setSeekerWidth={setSeekerWidth}
isFullscreen={isFullscreen}
isCaption={isCaption}
isCaptionEnabled={isCaptionEnabled}
disableFullscreen={disableFullscreen}
disableCaption={disableCaption}
toggleFullscreen={toggleFullscreen}
Expand Down
6 changes: 3 additions & 3 deletions packages/media-console/src/components/BottomControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ interface BottomControlsProps {
seekerPosition: number;
setSeekerWidth: Dispatch<SetStateAction<number>>;
isFullscreen: boolean;
isCaption: boolean;
isCaptionEnabled: boolean;
disableFullscreen: boolean;
disableCaption: boolean;
toggleFullscreen: () => void;
Expand All @@ -61,7 +61,7 @@ export const BottomControls = ({
seekerPosition,
setSeekerWidth,
isFullscreen,
isCaption,
isCaptionEnabled,
disableFullscreen,
disableCaption,
toggleFullscreen,
Expand Down Expand Up @@ -111,7 +111,7 @@ export const BottomControls = ({
<NullControl />
) : (
<Caption
isCaption={isCaption}
isCaptionEnabled={isCaptionEnabled}
toggleCaption={toggleCaption}
showControls={showControls}
/>
Expand Down
7 changes: 3 additions & 4 deletions packages/media-console/src/components/Caption.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,20 @@ import {Image, StyleSheet} from 'react-native';
import {Control} from './Control';

interface CaptionProps {
isCaption: boolean;
isCaptionEnabled: boolean;
toggleCaption: () => void;
showControls: boolean;
}

export const Caption = ({
isCaption,
isCaptionEnabled,
toggleCaption,

showControls,
}: CaptionProps) => {
return (
<Control
callback={toggleCaption}
style={[styles.caption, isCaption && styles.captionActive]}
style={[styles.caption, isCaptionEnabled && styles.captionActive]}
disabled={!showControls}>
<Image source={require('../assets/img/caption.png')} />
</Control>
Expand Down
2 changes: 1 addition & 1 deletion packages/media-console/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export interface VideoPlayerProps extends ReactVideoProps {
disableFullscreen?: boolean;

/**
* Show the caption button
* Hide the caption button
*
* @default false
*/
Expand Down

0 comments on commit fde8853

Please sign in to comment.