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 possibility to render an overlay component on video #131

Open
wants to merge 3 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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ allprojects {
| onHideControls | Callback for when the controls are being hide. |
| onShowControls | Callback for when the controls are being shown. |
| customStyles | The player can be customized in this object, see customStyles for the options. |
| renderOverlayComponent | Render an overlay component on top of the video, but under controls / play button. |

All other props are passed to the react-native-video component.

Expand Down
14 changes: 13 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ const styles = StyleSheet.create({
},
durationText: {
color: 'white'
}
},
overlayComponentWrapper: StyleSheet.absoluteFill,
});

export default class VideoPlayer extends Component {
Expand Down Expand Up @@ -427,6 +428,7 @@ export default class VideoPlayer extends Component {
]}
source={thumbnail}
>
{this.renderOverlay()}
{this.renderStartButton()}
</BackgroundImage>
);
Expand Down Expand Up @@ -521,6 +523,14 @@ export default class VideoPlayer extends Component {
);
}

renderOverlay() {
return this.props.renderOverlayComponent ? (
<View style={styles.overlayComponentWrapper}>
{this.props.renderOverlayComponent()}
</View>
) : null;
}

renderVideo() {
const {
video,
Expand Down Expand Up @@ -559,6 +569,7 @@ export default class VideoPlayer extends Component {
{ marginTop: -this.getSizeStyles().height },
]}
>
{this.renderOverlay()}
<TouchableOpacity
style={styles.overlayButton}
onPress={() => {
Expand Down Expand Up @@ -590,6 +601,7 @@ export default class VideoPlayer extends Component {
} else if (!isStarted) {
return (
<View style={[styles.preloadingPlaceholder, this.getSizeStyles(), style]}>
{this.renderOverlay()}
{this.renderStartButton()}
</View>
);
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-video-player",
"version": "0.14.0",
"version": "0.14.1",
"description": "A video player for React Native with controls",
"main": "index.js",
"scripts": {
Expand All @@ -21,7 +21,7 @@
"react": "*",
"react-native": "*",
"react-native-vector-icons": ">= 2.1.0",
"react-native-video": "^2.0.0"
"react-native-video": ">=5"
},
"devDependencies": {
"eslint": "^3.4.0",
Expand Down