Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add prop showOnEnd #42

Merged
merged 6 commits into from
Jan 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,24 +75,25 @@ You can pass any of the props that the `<Video />` component at [react-native-vi

In addition, the `<VideoPlayer />` also takes these props:

| Prop | Type | Default | Description |
|------------------------------|--------------|-------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| controlAnimationTiming | Integer | 500 | The amount of time (in milliseconds) to animate the controls in and out. |
| controlTimeoutDelay | Integer | 15000 | Hide controls after X amount of time in milliseconds | |
| doubleTapTime | Integer | 130 | Tapping twice within this amount of time in milliseconds is considered a double tap. Single taps will not be actioned until this time has expired. |
| isFullscreen | Boolean | false | The VideoPlayer fullscreen state |
| navigator | Navigator | null | 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 |
| rewindTime | Integer | 15 | Number of seconds to rewind or forward. |
| seekColor | String(#HEX) | '#FFF' | Fill/handle colour of the seekbar |
| showDuration | Boolean | false | Show duration of the media. |
| showOnStart | Boolean | false | Show or hide the controls on first render |
| showTimeRemaining | Boolean | false | If true, show the time remaing, else show the current time in the Player. |
| showHours | Boolean | false | If true, convert time to hours in the Player |
| tapAnywhereToPause | Boolean | false | If true, single tapping anywhere on the video (other than a control) toggles between playing and paused. |
| Prop | Type | Default | Description |
|---------------------|--------------|-------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| controlAnimationTiming | Integer | 500 | The amount of time (in milliseconds) to animate the controls in and out. |
| controlTimeoutDelay | Integer | 15000 | Hide controls after X amount of time in milliseconds | |
| doubleTapTime | Integer | 130 | Tapping twice within this amount of time in milliseconds is considered a double tap. Single taps will not be actioned until this time has expired. |
| isFullscreen | Boolean | false | The VideoPlayer fullscreen state |
| navigator | Navigator | null | 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 |
| rewindTime | Integer | 15 | Number of seconds to rewind or forward. |
| seekColor | String(#HEX) | '#FFF' | Fill/handle colour of the seekbar |
| showDuration | Boolean | false | Show duration of the media. |
| showOnStart | Boolean | false | Show or hide the controls on first render |
| showOnEnd | Boolean | false | Show or hide the controls on end of video |
| showTimeRemaining | Boolean | false | If true, show the time remaing, else show the current time in the Player. |
| showHours | Boolean | false | If true, convert time to hours in the Player |
| tapAnywhereToPause | Boolean | false | If true, single tapping anywhere on the video (other than a control) toggles between playing and paused. |
| toggleResizeModeOnFullscreen | Boolean | false | If true, clicking the fullscreen button will toggle the `<Video />` component between cover/contain, set to false if you want to customize fullscreen behaviour |
| containerStyle | ViewStyle | | StyleSheet passed to the container of the <Video /> component |
| videoStyle | ViewStyle | | StyleSheet passed to the <Video /> component |
| videoRef | Video | undefined | Pass ref to the `<Video/>` component |
| containerStyle | ViewStyle | | StyleSheet passed to the container of the <Video /> component |
| videoStyle | ViewStyle | | StyleSheet passed to the <Video /> component |
| videoRef | Video | undefined | Pass ref to the `<Video/>` component |

### Events

Expand Down
6 changes: 6 additions & 0 deletions src/VideoPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const VideoPlayer = (props: VideoPlayerProps) => {
resizeMode = 'contain',
isFullscreen = false,
showOnStart = false,
showOnEnd = false,
paused = false,
muted = false,
volume = 1,
Expand Down Expand Up @@ -126,7 +127,12 @@ export const VideoPlayer = (props: VideoPlayerProps) => {
if (currentTime < duration) {
setCurrentTime(duration);
setPaused(true);

if (showOnEnd) {
setShowControls(true);
}
}

if (typeof onEnd === 'function') {
onEnd();
}
Expand Down
7 changes: 7 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ export interface VideoPlayerProps extends VideoProperties {
*/
showOnStart?: boolean;

/**
* Show or hide the controls on end of video
*
* @default false
*/
showOnEnd?: boolean;

/**
* Title of the video
*/
Expand Down