Skip to content

Commit

Permalink
feat(autoplay): Add autoplay property
Browse files Browse the repository at this point in the history
  • Loading branch information
schenkfab committed Sep 17, 2016
1 parent 3835adf commit 1ca50b7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ To handle errors, you can pass a function to the `onError` prop:
);
```

To automatically play the video on page load:

```javascript
var Vimeo = require('react-vimeo');

React.render(
<Vimeo videoId={ videoId } autoplay='true' />,
$mountNode
);
```

## Behind the Scene

There are some things that you should know about the component. The first one is the structure created inside by the component if you wish to stylize it.
Expand Down
4 changes: 4 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Interface props {
onPlay?(data?: Object) => Void,
onPlayProgress?(data?: Object) => Void,
onSeek?(data?: Object) => Void,
autoplay?: Boolean = false,
};
```
Expand Down Expand Up @@ -63,4 +64,7 @@ Called when video play has progressed
## onSeek?(data: Object) => Void
Called when user seeks ahead in video
## autoplay?: Boolean = false
If true, video will automatically play
Interactive api (play/pause actions, seek to `n`, etc..) to come in future versions
7 changes: 5 additions & 2 deletions src/Vimeo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ export default React.createClass({
onSeek: PropTypes.func,
playButton: PropTypes.node,
videoId: PropTypes.string.isRequired,
playerOptions: PropTypes.object
playerOptions: PropTypes.object,
autoplay: PropTypes.bool
},

getDefaultProps() {
Expand All @@ -65,14 +66,16 @@ export default React.createClass({

defaults.className = 'vimeo';
defaults.playerOptions = { autoplay: 1 };
defaults.autoplay = false;
return defaults;
},

getInitialState() {
console.log('autplay', this.props.autoplay);
return {
imageLoaded: false,
playerOrigin: '*',
showingVideo: false,
showingVideo: this.props.autoplay,
thumb: null
};
},
Expand Down

0 comments on commit 1ca50b7

Please sign in to comment.