Skip to content

Commit

Permalink
Set correct initial state in ReactPlayer
Browse files Browse the repository at this point in the history
Partially fixes cookpete/react-player#2
  • Loading branch information
Webmaster1116 committed Sep 10, 2015
1 parent a06e85a commit c99fba0
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 c99fba0

Please sign in to comment.