Skip to content

Commit

Permalink
add "disableSeekButtons" property for hiding rewind/fast forward (#46)
Browse files Browse the repository at this point in the history
* add disableSeekForwardback property for hiding rewind/fast forward
  • Loading branch information
sam1463 authored Jan 25, 2023
1 parent efd6b52 commit 2a57648
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 12 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ These are the various controls that you can turn on/off as needed. All of these
| ----------------- | -------------------------- |
| disableFullscreen | Hide the fullscreen button |
| disablePlayPause | Hide the play/pause toggle and the rewind/forward buttons |
| disableSeekButtons | Hide the rewind/forward buttons (but not play/pause) |
| disableSeekbar | Hide the seekbar |
| disableVolume | Hide the Volume control |
| disableTimer | Hide the timer |
Expand Down
2 changes: 2 additions & 0 deletions src/VideoPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export const VideoPlayer = (props: VideoPlayerProps) => {
disableTimer = false,
disableSeekbar = false,
disablePlayPause = false,
disableSeekButtons = false,
navigator,
rewindTime = 15,
} = props;
Expand Down Expand Up @@ -420,6 +421,7 @@ export const VideoPlayer = (props: VideoPlayerProps) => {
<PlayPause
animations={animations}
disablePlayPause={disablePlayPause}
disableSeekButtons={disableSeekButtons}
paused={_paused}
togglePlayPause={togglePlayPause}
resetControlTimeout={resetControlTimeout}
Expand Down
34 changes: 22 additions & 12 deletions src/components/PlayPause/PlayPause.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const playPauseRef = createRef<TouchableHighlight>();
interface PlayPauseProps {
animations: VideoAnimations;
disablePlayPause: boolean;
disableSeekButtons: boolean;
paused: boolean;
togglePlayPause: () => void;
resetControlTimeout: () => void;
Expand All @@ -26,6 +27,7 @@ const forward = require('../../assets/img/forward.png');
export const PlayPause = ({
animations,
disablePlayPause,
disableSeekButtons,
paused,
togglePlayPause,
resetControlTimeout,
Expand All @@ -48,12 +50,14 @@ export const PlayPause = ({
<Animated.View
pointerEvents={'box-none'}
style={[styles.container, animatedStyles]}>
<Control
disabled={!showControls}
callback={onPressRewind}
resetControlTimeout={resetControlTimeout}>
<Image source={rewind} resizeMode={'contain'} style={styles.rewind} />
</Control>
{!disableSeekButtons ? (
<Control
disabled={!showControls}
callback={onPressRewind}
resetControlTimeout={resetControlTimeout}>
<Image source={rewind} resizeMode={'contain'} style={styles.rewind} />
</Control>
) : null}
<Control
disabled={!showControls}
callback={togglePlayPause}
Expand All @@ -63,12 +67,18 @@ export const PlayPause = ({
{...(Platform.isTV ? {hasTVPreferredFocus: showControls} : {})}>
<Image source={source} resizeMode={'contain'} style={styles.play} />
</Control>
<Control
disabled={!showControls}
callback={onPressForward}
resetControlTimeout={resetControlTimeout}>
<Image source={forward} resizeMode={'contain'} style={styles.rewind} />
</Control>
{!disableSeekButtons ? (
<Control
disabled={!showControls}
callback={onPressForward}
resetControlTimeout={resetControlTimeout}>
<Image
source={forward}
resizeMode={'contain'}
style={styles.rewind}
/>
</Control>
) : null}
</Animated.View>
);
};
8 changes: 8 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,14 @@ export interface VideoPlayerProps extends VideoProperties {
* @default false
*/
disablePlayPause?: boolean;

/**
* Hide the rewind/forward buttons without hiding the play/pause button
*
* @default false
*/
disableSeekButtons?: boolean;

/**
* When using the default React Native navigator and do not override the `onBack` function,
* you'll need to pass the navigator to the VideoPlayer for it to function
Expand Down

0 comments on commit 2a57648

Please sign in to comment.