diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-05-21 21:18:35 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-05-21 21:18:35 +0200 |
| commit | 4711e2988c91bdf0a70525ffe18040d1b8158b9a (patch) | |
| tree | b91f62bb63c9c04db1d1f32173539c6ce3bd9c4a /app/client/live/reducer.js | |
| parent | af3bed7b5b1b01531e3bb34c56612c37717e06b7 (diff) | |
add saving to disk
Diffstat (limited to 'app/client/live/reducer.js')
| -rw-r--r-- | app/client/live/reducer.js | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/app/client/live/reducer.js b/app/client/live/reducer.js index e056808..a043df3 100644 --- a/app/client/live/reducer.js +++ b/app/client/live/reducer.js @@ -1,11 +1,13 @@ import { combineReducers } from 'redux' +import moment from 'moment' +let FileSaver = require('file-saver') const liveInitialState = { loading: false, error: null, opt: {}, checkpoints: [], - checkpoint_dir: ['latest'], + epochs: ['latest'], sequences: [], fps: 0, frame: { i: 0, sequence_i: 0, sequence_len: '1' } @@ -68,6 +70,39 @@ const liveReducer = (state = liveInitialState, action) => { frame: action.meta } : state + case 'START_RECORDING': + return { + ...state, + opt: { + ...state.opt, + recording: true, + } + } + + case 'SAVE_FRAME': + FileSaver.saveAs( + action.blob, + state.opt.checkpoint_name + "_" + + state.opt.sequence + "_" + + moment().format("YYYYMMDD_HHmm") + ".png" + ) + return state + + case 'SAVE_VIDEO': + FileSaver.saveAs( + action.blob, + state.opt.checkpoint_name + "_" + + state.opt.sequence + "_" + + moment().format("YYYYMMDD_HHmm") + ".webm" + ) + return { + ...state, + opt: { + ...state.opt, + recording: false, + } + } + default: return state } |
