From 180039b19b3975e7e0ecae1202ccb304d829fba7 Mon Sep 17 00:00:00 2001 From: Pete Cook Date: Wed, 27 Jul 2016 21:45:27 +0100 Subject: [PATCH] Stop progress loop on pause To prevent the delayed progress event after pausing, and ensure #51 doesn't happen again --- src/ReactPlayer.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/ReactPlayer.js b/src/ReactPlayer.js index 02916a14..9090e04c 100644 --- a/src/ReactPlayer.js +++ b/src/ReactPlayer.js @@ -14,6 +14,14 @@ export default class ReactPlayer extends Component { componentDidMount () { this.progress() } + componentWillReceiveProps (nextProps) { + if (this.props.playing && !nextProps.playing) { + clearTimeout(this.progressTimeout) + } + if (!this.props.playing && nextProps.playing) { + this.progress() + } + } componentWillUnmount () { clearTimeout(this.progressTimeout) }