Skip to content

Commit

Permalink
Refresh vimeo duration on play
Browse files Browse the repository at this point in the history
Previously, duration was only set on `loaded`, which returns 0 if the video is password protected
Fixes cookpete/react-player#514
  • Loading branch information
Webmaster1116 committed Nov 17, 2018
1 parent 69eba01 commit b58d510
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/players/Vimeo.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ export class Vimeo extends Component {
}).catch(this.props.onError)
this.player.on('loaded', () => {
this.props.onReady()
this.player.getDuration().then(duration => {
this.duration = duration
})
this.refreshDuration()
})
this.player.on('play', () => {
this.props.onPlay()
this.refreshDuration()
})
this.player.on('play', this.props.onPlay)
this.player.on('pause', this.props.onPause)
this.player.on('seeked', e => this.props.onSeek(e.seconds))
this.player.on('ended', this.props.onEnded)
Expand All @@ -56,6 +57,11 @@ export class Vimeo extends Component {
})
}, this.props.onError)
}
refreshDuration () {
this.player.getDuration().then(duration => {
this.duration = duration
})
}
play () {
this.callPlayer('play')
}
Expand Down

0 comments on commit b58d510

Please sign in to comment.