diff options
author | Thibaut Girka <thib@sitedethib.com> | 2018-08-14 18:21:29 +0200 |
---|---|---|
committer | ThibG <thib@sitedethib.com> | 2018-08-14 21:56:23 +0200 |
commit | 494eaab5b137cb69122566d6e65f001c0e969deb (patch) | |
tree | 8d8f2068b701d32971d0e5f0f19129b533c8aa87 /app/javascript/flavours | |
parent | c4e8402ef9d8e0832347cf06b79ba57cfd9f0526 (diff) |
Slightly more aggressive video preloading
- Preload video metadata if the video is loaded in detailed view, as it is likely to get played, and metadata is useful for seeking in the video. - Preload video data if it's fullscreen as it is extremely likely to get played right after being put in fullscreen (although those are two steps). - Preload video data if the user has clicked the position slider, as the video will play as soon as the mouse button is released, and video metadata is needed to properly seek into the video.
Diffstat (limited to 'app/javascript/flavours')
-rw-r--r-- | app/javascript/flavours/glitch/features/video/index.js | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/app/javascript/flavours/glitch/features/video/index.js b/app/javascript/flavours/glitch/features/video/index.js index 4823ac274..a578df026 100644 --- a/app/javascript/flavours/glitch/features/video/index.js +++ b/app/javascript/flavours/glitch/features/video/index.js @@ -295,6 +295,15 @@ export default class Video extends React.PureComponent { warning = <FormattedMessage id='status.media_hidden' defaultMessage='Media hidden' />; } + let preload; + if (startTime || fullscreen || dragging) { + preload = 'auto'; + } else if (detailed) { + preload = 'metadata'; + } else { + preload = 'none'; + } + return ( <div className={classNames('video-player', { inactive: !revealed, detailed, inline: inline && !fullscreen, fullscreen, letterbox, 'full-width': fullwidth })} @@ -309,7 +318,7 @@ export default class Video extends React.PureComponent { ref={this.setVideoRef} src={src} poster={preview} - preload={startTime ? 'auto' : 'none'} + preload={preload} loop role='button' tabIndex='0' |