diff options
author | ThibG <thib@sitedethib.com> | 2020-11-25 19:01:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-25 19:01:15 +0100 |
commit | 29812c2e59e02ea5ff8e4818a38b59944e2367ba (patch) | |
tree | 481dc4c0158a2def1e41f5998ef67a4e3707bb8b /app/javascript/flavours/glitch/features/video | |
parent | 24696458bf22c8529b49f89b2791e3e07583b7e0 (diff) | |
parent | b9fc807115e83347ad7bb74cd3ff82841c35809a (diff) |
Merge pull request #1468 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/javascript/flavours/glitch/features/video')
-rw-r--r-- | app/javascript/flavours/glitch/features/video/index.js | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/app/javascript/flavours/glitch/features/video/index.js b/app/javascript/flavours/glitch/features/video/index.js index ea40b6073..92dcaf473 100644 --- a/app/javascript/flavours/glitch/features/video/index.js +++ b/app/javascript/flavours/glitch/features/video/index.js @@ -98,6 +98,7 @@ class Video extends React.PureComponent { static propTypes = { preview: PropTypes.string, + frameRate: PropTypes.string, src: PropTypes.string.isRequired, alt: PropTypes.string, width: PropTypes.number, @@ -125,6 +126,10 @@ class Video extends React.PureComponent { muted: PropTypes.bool, }; + static defaultProps = { + frameRate: 25, + }; + state = { currentTime: 0, duration: 0, @@ -298,7 +303,7 @@ class Video extends React.PureComponent { } handleKeyDown = e => { - const frameTime = 1 / 25; + const frameTime = 1 / this.getFrameRate(); switch(e.key) { case 'k': @@ -531,6 +536,17 @@ class Video extends React.PureComponent { this.props.onCloseVideo(); } + getFrameRate () { + if (this.props.frameRate && isNaN(this.props.frameRate)) { + // The frame rate is returned as a fraction string so we + // need to convert it to a number + + return this.props.frameRate.split('/').reduce((p, c) => p / c); + } + + return this.props.frameRate || 25; + } + render () { const { preview, src, inline, onOpenVideo, onCloseVideo, intl, alt, letterbox, fullwidth, detailed, sensitive, link, editable, blurhash } = this.props; const { containerWidth, currentTime, duration, volume, buffer, dragging, paused, fullscreen, hovered, muted, revealed } = this.state; |