Skip to content

Commit

Permalink
Set correct initial state in ReactPlayer
Browse files Browse the repository at this point in the history
Partially fixes #2
  • Loading branch information
cookpete committed Sep 10, 2015
1 parent 61bc61e commit f912f13
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/ReactPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,18 @@ export default class MediaPlayer extends Component {
return players.some(player => player.canPlay(url))
}
state = {
Player: null
Player: this.getPlayer(this.props.url)
}
componentWillReceiveProps (nextProps) {
if (this.props.url !== nextProps.url) {
this.setState({
Player: players.find(Player => Player.canPlay(nextProps.url))
Player: this.getPlayer(nextProps.url)
})
}
}
getPlayer (url) {
return players.find(Player => Player.canPlay(url))
}
seekTo = fraction => {
let player = this.refs.player
if (player) {
Expand Down

0 comments on commit f912f13

Please sign in to comment.