Display streamdelay stream duration

This commit is contained in:
Max Goodhart
2021-03-14 17:10:51 -07:00
parent e7bd4a674c
commit bd1dc48574
3 changed files with 25 additions and 0 deletions

5
package-lock.json generated
View File

@@ -8708,6 +8708,11 @@
"resolved": "https://registry.npmjs.org/lru_map/-/lru_map-0.3.3.tgz", "resolved": "https://registry.npmjs.org/lru_map/-/lru_map-0.3.3.tgz",
"integrity": "sha1-tcg1G5Rky9dQM1p5ZQoOwOVhGN0=" "integrity": "sha1-tcg1G5Rky9dQM1p5ZQoOwOVhGN0="
}, },
"luxon": {
"version": "1.26.0",
"resolved": "https://registry.npmjs.org/luxon/-/luxon-1.26.0.tgz",
"integrity": "sha512-+V5QIQ5f6CDXQpWNICELwjwuHdqeJM1UenlZWx5ujcRMc9venvluCjFb4t5NYLhb6IhkbMVOxzVuOqkgMxee2A=="
},
"make-dir": { "make-dir": {
"version": "2.1.0", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/make-dir/-/make-dir-2.1.0.tgz", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-2.1.0.tgz",

View File

@@ -29,6 +29,7 @@
"koa-static": "^5.0.0", "koa-static": "^5.0.0",
"koa-views": "^6.3.0", "koa-views": "^6.3.0",
"lodash": "^4.17.19", "lodash": "^4.17.19",
"luxon": "^1.26.0",
"node-fetch": "^2.6.0", "node-fetch": "^2.6.0",
"node-simple-cert": "0.0.1", "node-simple-cert": "0.0.1",
"preact": "^10.4.4", "preact": "^10.4.4",

View File

@@ -16,6 +16,7 @@ import { State } from 'xstate'
import styled, { createGlobalStyle } from 'styled-components' import styled, { createGlobalStyle } from 'styled-components'
import { useHotkeys } from 'react-hotkeys-hook' import { useHotkeys } from 'react-hotkeys-hook'
import Color from 'color' import Color from 'color'
import { DateTime } from 'luxon'
import '../index.css' import '../index.css'
import { idxInBox } from '../geometry' import { idxInBox } from '../geometry'
@@ -798,6 +799,21 @@ const Stack = styled.div`
${({ minHeight }) => minHeight && `min-height: ${minHeight}px`}; ${({ minHeight }) => minHeight && `min-height: ${minHeight}px`};
` `
function StreamDurationClock({ startTime }) {
const [now, setNow] = useState(() => DateTime.now())
useEffect(() => {
const interval = setInterval(() => {
setNow(DateTime.now())
}, 500)
return () => {
clearInterval(interval)
}
}, [startTime])
return (
<span>{now.diff(DateTime.fromMillis(startTime)).toFormat('hh:mm:ss')}</span>
)
}
function StreamDelayBox({ function StreamDelayBox({
role, role,
delayState, delayState,
@@ -830,6 +846,9 @@ function StreamDelayBox({
{!delayState.isStreamRunning && <span>stream stopped</span>} {!delayState.isStreamRunning && <span>stream stopped</span>}
{delayState.isConnected && ( {delayState.isConnected && (
<> <>
{delayState.startTime !== null && (
<StreamDurationClock startTime={delayState.startTime} />
)}
<span>delay: {delayState.delaySeconds}s</span> <span>delay: {delayState.delaySeconds}s</span>
{delayState.isStreamRunning && ( {delayState.isStreamRunning && (
<StyledButton <StyledButton