diff options
author | ThibG <thib@sitedethib.com> | 2020-04-25 12:16:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-25 12:16:05 +0200 |
commit | c955f98d36868e85b0f1939a3a1c58c00babd4e8 (patch) | |
tree | effaf743cd9f3d552b8754694369bafdcb596e3d /app/javascript/mastodon/features/video/index.js | |
parent | 46b2cc184fab294f540b3cc1ffa3d9e6ac2c9fbf (diff) |
Fix expanded video player issues (#13541)
Fixes #13536 - Expanding a paused video doesn't autoplay anymore - Default volume level for the expanded video inherited from the original video Position/playing state/volume are carried over from the original video player to the modal, but they're not reported back to the modal as it would require deeper changes.
Diffstat (limited to 'app/javascript/mastodon/features/video/index.js')
-rw-r--r-- | app/javascript/mastodon/features/video/index.js | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/app/javascript/mastodon/features/video/index.js b/app/javascript/mastodon/features/video/index.js index 42ded9d21..95e107618 100644 --- a/app/javascript/mastodon/features/video/index.js +++ b/app/javascript/mastodon/features/video/index.js @@ -109,6 +109,8 @@ class Video extends React.PureComponent { intl: PropTypes.object.isRequired, blurhash: PropTypes.string, link: PropTypes.node, + autoPlay: PropTypes.bool, + defaultVolume: PropTypes.number, }; state = { @@ -367,6 +369,13 @@ class Video extends React.PureComponent { handleLoadedData = () => { if (this.props.startTime) { this.video.currentTime = this.props.startTime; + } + + if (this.props.defaultVolume !== undefined) { + this.video.volume = this.props.defaultVolume; + } + + if (this.props.autoPlay) { this.video.play(); } } @@ -393,8 +402,14 @@ class Video extends React.PureComponent { height, }); + const options = { + startTime: this.video.currentTime, + autoPlay: !this.state.paused, + defaultVolume: this.state.volume, + }; + this.video.pause(); - this.props.onOpenVideo(media, this.video.currentTime); + this.props.onOpenVideo(media, options); } handleCloseVideo = () => { |