From 5665094fd03f51a302b9123e2c2dc1c34cb05d8a Mon Sep 17 00:00:00 2001 From: mgabdev <> Date: Wed, 10 Jun 2020 20:30:11 -0400 Subject: [PATCH] Updated Video Component x2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Updated: - Video Component x2 - Smooth seek transition with linear - Hide large center play, volume slider, pip on mobile - Update to buffering --- app/javascript/gabsocial/components/video.js | 73 +++++++++++--------- app/javascript/styles/global.css | 4 ++ 2 files changed, 46 insertions(+), 31 deletions(-) diff --git a/app/javascript/gabsocial/components/video.js b/app/javascript/gabsocial/components/video.js index 0e7da5f7..7cff006e 100644 --- a/app/javascript/gabsocial/components/video.js +++ b/app/javascript/gabsocial/components/video.js @@ -13,13 +13,16 @@ import { displayMedia } from '../initial_state' import { CX, POPOVER_VIDEO_STATS, + BREAKPOINT_EXTRA_SMALL, } from '../constants' +import Responsive from '../features/ui/util/responsive_component' import Button from './button' import Icon from './icon' import Text from './text' -// check every 50 ms (do not use lower values) -const checkInterval = 50.0 +// check every 50 ms for buffer +const checkInterval = 50 +const FIXED_VAR = 6 const messages = defineMessages({ play: { id: 'video.play', defaultMessage: 'Play' }, @@ -37,7 +40,7 @@ const messages = defineMessages({ const formatTime = (secondsNum) => { let hours = Math.floor(secondsNum / 3600) let minutes = Math.floor((secondsNum - (hours * 3600)) / 60) - let seconds = secondsNum - (hours * 3600) - (minutes * 60) + let seconds = Math.floor(secondsNum) - (hours * 3600) - (minutes * 60) if (hours < 10) hours = '0' + hours if (minutes < 10) minutes = '0' + minutes @@ -203,12 +206,11 @@ class Video extends ImmutablePureComponent { } checkBuffering = () => { - const { isBuffering, paused } = this.state - const { currentTime } = this.video + const { isBuffering, paused, currentTime } = this.state // checking offset should be at most the check interval // but allow for some margin - let offset = (checkInterval - 20) / 1000 + let offset = checkInterval / 1000 // if no buffering is currently detected, // and the position does not seem to increase @@ -279,7 +281,10 @@ class Video extends ImmutablePureComponent { } handlePause = () => { - this.setState({ paused: true }) + this.setState({ + paused: true, + isBuffering: false, + }) clearInterval(this.bufferCheckInterval) } @@ -287,8 +292,8 @@ class Video extends ImmutablePureComponent { handleTimeUpdate = () => { const { currentTime, duration } = this.video this.setState({ - currentTime: Math.floor(currentTime), - duration: Math.floor(duration), + currentTime: currentTime.toFixed(FIXED_VAR), + duration: duration.toFixed(FIXED_VAR), }) } @@ -359,7 +364,7 @@ class Video extends ImmutablePureComponent { handleMouseMove = throttle(e => { const { x } = getPointerPosition(this.seek, e) - const currentTime = Math.floor(this.video.duration * x) + const currentTime = parseFloat(this.video.duration * x).toFixed(FIXED_VAR) if (!isNaN(currentTime)) { this.video.currentTime = currentTime @@ -576,6 +581,7 @@ class Video extends ImmutablePureComponent { z3: 1, alignItemsCenter: 1, justifyContentCenter: 1, + videoEase: 1, opacity0: !dragging, opacity1: dragging || hovered, }) @@ -595,6 +601,7 @@ class Video extends ImmutablePureComponent { mt10: 1, posAbs: 1, height4PX: 1, + videoEase: 1, }) const volumeControlClasses = CX({ @@ -654,15 +661,17 @@ class Video extends ImmutablePureComponent {