From ea5c7dfcc88f345b44e13b1a8d23ac5bd11c7150 Mon Sep 17 00:00:00 2001 From: Jonathan Baudanza Date: Mon, 12 Feb 2018 12:02:40 +0900 Subject: [PATCH] The user can adjust the playback rate --- src/components/Source.js | 42 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/src/components/Source.js b/src/components/Source.js index f83c088..1153ca4 100644 --- a/src/components/Source.js +++ b/src/components/Source.js @@ -46,10 +46,23 @@ class VideoMedia extends Component { } } + setVideoRef = (el) => { + this.videoElem = el; + if (this.videoElem) { + this.videoElem.playbackRate = this.props.playbackRate; + } + } + + componentDidUpdate(prevProps, prevState) { + if (prevProps.playbackRate !== this.props.playbackRate && this.videoElem) { + this.videoElem.playbackRate = this.props.playbackRate; + } + } + render() { const { media, initialTime, onTimeUpdate, onPlaying, onPause, onEnded, onSeeking } = this.props; return ( -