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

Pause/play pressing player anywhere by default #172

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ allprojects {
| onStart | Callback for when the start button is pressed. |
| onPlayPress | Callback for when the play button is pressed. |
| onHideControls | Callback for when the controls are being hide. |
| onShowControls | Callback for when the controls are being shown. |
| onShowControls | Callback for when the controls are being shown.
| onThumbnailError | Callback for when the thumnail image fails to load |
| customStyles | The player can be customized in this object, see customStyles for the options. |

All other props are passed to the react-native-video component.
Expand Down
9 changes: 3 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ export default class VideoPlayer extends Component {
}

renderThumbnail(thumbnail) {
const { style, customStyles, ...props } = this.props;
const { style, customStyles, onThumbnailError, ...props } = this.props;
return (
<BackgroundImage
{...props}
Expand All @@ -426,6 +426,7 @@ export default class VideoPlayer extends Component {
customStyles.thumbnail,
]}
source={thumbnail}
onError={onThumbnailError}
>
{this.renderStartButton()}
</BackgroundImage>
Expand Down Expand Up @@ -526,7 +527,6 @@ export default class VideoPlayer extends Component {
video,
style,
resizeMode,
pauseOnPress,
fullScreenOnLongPress,
customStyles,
...props
Expand Down Expand Up @@ -563,8 +563,7 @@ export default class VideoPlayer extends Component {
style={styles.overlayButton}
onPress={() => {
this.showControls();
if (pauseOnPress)
this.onPlayPress();
this.onPlayPress();
}}
onLongPress={() => {
if (fullScreenOnLongPress && Platform.OS !== 'android')
Expand Down Expand Up @@ -626,7 +625,6 @@ VideoPlayer.propTypes = {
hideControlsOnStart: PropTypes.bool,
endWithThumbnail: PropTypes.bool,
disableSeek: PropTypes.bool,
pauseOnPress: PropTypes.bool,
fullScreenOnLongPress: PropTypes.bool,
customStyles: PropTypes.shape({
wrapper: ViewPropTypesVar.style,
Expand Down Expand Up @@ -667,7 +665,6 @@ VideoPlayer.defaultProps = {
loop: false,
resizeMode: 'contain',
disableSeek: false,
pauseOnPress: false,
fullScreenOnLongPress: false,
customStyles: {},
showDuration: false
Expand Down