From 6f03892afc82d95fe886fb140eb954835582ad90 Mon Sep 17 00:00:00 2001 From: Pete Cook Date: Sat, 17 Nov 2018 16:15:48 +0000 Subject: [PATCH] Refresh vimeo duration on play Previously, duration was only set on `loaded`, which returns 0 if the video is password protected Fixes https://github.com/CookPete/react-player/issues/514 --- src/players/Vimeo.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/players/Vimeo.js b/src/players/Vimeo.js index 0030eecd..423da80d 100644 --- a/src/players/Vimeo.js +++ b/src/players/Vimeo.js @@ -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) @@ -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') }