Skip to content

Commit 87eb6f3

Browse files
committed
Merge branch 'patch-1' of https://github.com/mosch/react-video into mosch-patch-1
* 'patch-1' of https://github.com/mosch/react-video: Update README.md fixed syntax errors fixed reference to id Added auto-detection for "from" attribute Conflicts: README.md lib/react-video.jsx
2 parents 5b37c46 + 1523ee1 commit 87eb6f3

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Installing this component is very easy and it has just one dependency: [React](h
2020
$ bower install --save react-video
2121
```
2222

23-
- Or if you want to [download the lastest release](https://github.com/pedronauck/react-video/archive/v1.2.0.zip) and put in your website, it will work too!
23+
- Or if you want to [download the lastest release](https://github.com/pedronauck/react-video/archive/v1.3.0.zip) and put in your website, it will work too!
2424

2525
**NOTICE:** You need just one thing to make the component work. Put the [base component style](./dist/react-video.css) at the `<header>` tag. If you don't wanna use the `.css` extension, you can get the `.styl` or `.scss` extension at the folder `./lib`.
2626

@@ -86,7 +86,7 @@ For more details, check out the API below.
8686

8787
Property | Type | Default | Required | Description
8888
-------- | ---- | ------- | -------- |-----------
89-
from | `String` | none | yes | Video source: `youtube` or `vimeo`
89+
from | `String` | none | no | Video source: `youtube` or `vimeo`. Leave empty and the service will be detected for you by looking a the id.
9090
videoId | `String` | none | yes | The video ID
9191

9292
## Contributing

lib/react-video.jsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ var Spinner = require('./components/spinner');
77
module.exports = React.createClass({
88
displayName: 'Video',
99
propTypes: {
10-
from: React.PropTypes.oneOf(['youtube', 'vimeo']).isRequired,
10+
from: React.PropTypes.oneOf(['youtube', 'vimeo']),
1111
videoId: React.PropTypes.string.isRequired
1212
},
1313
getDefaultProps() {
@@ -22,9 +22,15 @@ module.exports = React.createClass({
2222
showingVideo: false
2323
};
2424
},
25+
isYoutube() {
26+
return this.props.from === 'youtube' || isNaN(this.props.id);
27+
},
28+
isVimeo() {
29+
return this.props.from === 'vimeo' || !isNaN(this.props.id);
30+
},
2531
componentDidMount() {
26-
this.props.from === 'youtube' && this.fetchYoutubeData();
27-
this.props.from === 'vimeo' && this.fetchVimeoData();
32+
this.isYoutube() && this.fetchYoutubeData();
33+
this.isVimeo() && this.fetchVimeoData();
2834
},
2935
render() {
3036
return (
@@ -68,10 +74,10 @@ module.exports = React.createClass({
6874
ev.preventDefault();
6975
},
7076
getIframeUrl() {
71-
if (this.props.from === 'youtube') {
77+
if (this.isYoutube()) {
7278
return `//youtube.com/embed/${this.props.videoId}?autoplay=1`
7379
}
74-
else if (this.props.from === 'vimeo') {
80+
else if (this.isVimeo()) {
7581
return `//player.vimeo.com/video/${this.props.videoId}?autoplay=1`
7682
}
7783
},

0 commit comments

Comments
 (0)