From: ThibG Date: Sun, 27 Jan 2019 20:18:15 +0000 (+0100) Subject: Fix initial value of volume slider in video player and handle volume changes (#9929) X-Git-Url: https://git.xn--scling-oua.cat.family/?a=commitdiff_plain;h=a53dcaa29869e808707efcba541b02ee8d799e75;p=mastodon.git Fix initial value of volume slider in video player and handle volume changes (#9929) * Fix initial value of volume slider in video player and handle volume changes * Clean up dead/incorrect code --- diff --git a/app/javascript/mastodon/features/video/index.js b/app/javascript/mastodon/features/video/index.js index 3650fddb6..0d0c24d71 100644 --- a/app/javascript/mastodon/features/video/index.js +++ b/app/javascript/mastodon/features/video/index.js @@ -136,6 +136,9 @@ class Video extends React.PureComponent { setVideoRef = c => { this.video = c; + if (this.video) { + this.setState({ volume: this.video.volume, muted: this.video.muted }); + } } setSeekRef = c => { @@ -302,6 +305,10 @@ class Video extends React.PureComponent { } } + handleVolumeChange = () => { + this.setState({ volume: this.video.volume, muted: this.video.muted }); + } + handleOpenVideo = () => { const { src, preview, width, height, alt } = this.props; const media = fromJS({ @@ -387,6 +394,7 @@ class Video extends React.PureComponent { onTimeUpdate={this.handleTimeUpdate} onLoadedData={this.handleLoadedData} onProgress={this.handleProgress} + onVolumeChange={this.handleVolumeChange} /> - +