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/live.reducer.js | 14 +++++++++++++- app/client/live/player.js | 43 ++++++++++++++++++++++++++++++----------- 2 files changed, 45 insertions(+), 12 deletions(-) (limited to 'app/client/live') diff --git a/app/client/live/live.reducer.js b/app/client/live/live.reducer.js index 60bcb41..e7ef569 100644 --- a/app/client/live/live.reducer.js +++ b/app/client/live/live.reducer.js @@ -10,6 +10,7 @@ const liveInitialState = { epochs: ['latest'], sequences: [], fps: 0, + playing: false, frame: { i: 0, sequence_i: 0, sequence_len: '1' } } @@ -70,6 +71,18 @@ const liveReducer = (state = liveInitialState, action) => { frame: action.meta } : state + case types.player.pausing: + return { + ...state, + playing: false, + } + + case types.player.playing: + return { + ...state, + playing: true, + } + case types.player.start_recording: return { ...state, @@ -86,7 +99,6 @@ const liveReducer = (state = liveInitialState, action) => { recordFrames: (state.opt.recordFrames || 0) + 1, } } - case types.player.save_frame: FileSaver.saveAs( action.blob, 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