]> cat aescling's git repositories - mastodon.git/commitdiff
[Glitch] Fix hardcoded frame rate for frame by frame video navigation in web UI
authorEugen Rochko <eugen@zeonfederated.com>
Sat, 21 Nov 2020 22:19:04 +0000 (23:19 +0100)
committerThibaut Girka <thib@sitedethib.com>
Wed, 25 Nov 2020 14:46:09 +0000 (15:46 +0100)
Port f970e1fab6ca5d2334604b86d6e472e64510ea40 to glitch-soc

Signed-off-by: Thibaut Girka <thib@sitedethib.com>
app/javascript/flavours/glitch/components/status.js
app/javascript/flavours/glitch/features/status/components/detailed_status.js
app/javascript/flavours/glitch/features/ui/components/focal_point_modal.js
app/javascript/flavours/glitch/features/ui/components/video_modal.js
app/javascript/flavours/glitch/features/video/index.js

index 1b7dce4c4a56052850e6f9381fdd364a1d318361..fcbf4be8c3426c136cb486766cda1a701d379a8a 100644 (file)
@@ -628,6 +628,7 @@ class Status extends ImmutablePureComponent {
           <Bundle fetchComponent={Video} loading={this.renderLoadingVideoPlayer} >
             {Component => (<Component
               preview={attachment.get('preview_url')}
+              frameRate={attachment.getIn(['meta', 'original', 'frame_rate'])}
               blurhash={attachment.get('blurhash')}
               src={attachment.get('url')}
               alt={attachment.get('description')}
index 04d350bcbe47b7608455053a04d8b3b340929fa8..40bf370f31fd3338ec143254d5a021726c021fb6 100644 (file)
@@ -160,6 +160,7 @@ export default class DetailedStatus extends ImmutablePureComponent {
         media = (
           <Video
             preview={attachment.get('preview_url')}
+            frameRate={attachment.getIn(['meta', 'original', 'frame_rate'])}
             blurhash={attachment.get('blurhash')}
             src={attachment.get('url')}
             alt={attachment.get('description')}
index 5de3e26d513ba9739782e05246f8bbaef8fac157..2485d9ae36512ddd66525c3905a0e82de2a66b13 100644 (file)
@@ -386,6 +386,7 @@ class FocalPointModal extends ImmutablePureComponent {
             {media.get('type') === 'video' && (
               <Video
                 preview={media.get('preview_url')}
+                frameRate={media.getIn(['meta', 'original', 'frame_rate'])}
                 blurhash={media.get('blurhash')}
                 src={media.get('url')}
                 detailed
index c8d2a81b0cd7d33773705600f7df057b220eb6b8..b0a4f3f034bfd96e32dab59a734253ecb4a0a29e 100644 (file)
@@ -40,6 +40,7 @@ export default class VideoModal extends ImmutablePureComponent {
         <div className='video-modal__container'>
           <Video
             preview={media.get('preview_url')}
+            frameRate={media.getIn(['meta', 'original', 'frame_rate'])}
             blurhash={media.get('blurhash')}
             src={media.get('url')}
             currentTime={options.startTime}
index ea40b6073dfe60377b7cf4aad212d4275632533e..7e8996af4fabdad9bf95fc7904c10327cb7117c0 100644 (file)
@@ -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;
+  }
+
   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;