From fe8cef1b709f09f508f17d0d6d06f204dd44a8bb Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 29 May 2018 18:51:27 +0200 Subject: pushing files to s3.. filelist color --- app/client/live/player.js | 43 ++++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-) (limited to 'app/client/live/player.js') diff --git a/app/client/live/player.js b/app/client/live/player.js index 808e79e..37f7cab 100644 --- a/app/client/live/player.js +++ b/app/client/live/player.js @@ -66,15 +66,36 @@ export function onFrame (data) { img.src = url } -setInterval(() => { - store.dispatch({ - type: types.player.set_fps, - fps: fps, - }) - store.dispatch({ - type: types.player.current_frame, - meta: last_frame, - }) - fps = 0 -}, 1000) +let previousValue, currentValue +function handleChange() { + let previousValue = currentValue + currentValue = store.getState().live.playing + + if (previousValue !== currentValue) { + if (currentValue) { + startWatchingFPS() + } else { + stopWatchingFPS() + } + } +} + +let fpsInterval; +function startWatchingFPS(){ + clearInterval(fpsInterval) + fpsInterval = setInterval(() => { + store.dispatch({ + type: types.player.set_fps, + fps: fps, + }) + store.dispatch({ + type: types.player.current_frame, + meta: last_frame, + }) + fps = 0 + }, 1000) +} +function stopWatchingFPS(){ + clearInterval(fpsInterval) +} \ No newline at end of file -- cgit v1.2.3-70-g09d2