From 4a4306c662a139323b1011e232c23ebe74083755 Mon Sep 17 00:00:00 2001 From: Xuan L <138820189+XnThanh@users.noreply.github.com> Date: Thu, 14 Dec 2023 18:16:18 +0100 Subject: [PATCH] Added state wrapper functions --- .../src/state/PlaybackStateProvider.jsx | 30 +++++++++++++++++++ .../frontend/src/state/VideoDataProvider.jsx | 15 +++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/src/icatcher/icatcher_app/frontend/src/state/PlaybackStateProvider.jsx b/src/icatcher/icatcher_app/frontend/src/state/PlaybackStateProvider.jsx index 29db2ed..3d144d8 100644 --- a/src/icatcher/icatcher_app/frontend/src/state/PlaybackStateProvider.jsx +++ b/src/icatcher/icatcher_app/frontend/src/state/PlaybackStateProvider.jsx @@ -65,6 +65,9 @@ function playbackStateReducer(playbackState, action) { frameRange: action.frameRange }; } + case 'resetState': { + return initialPlaybackState; + } default: { throw Error('Unknown action: ' + action.type); } @@ -148,4 +151,31 @@ const getMinMaxFrames = (videoData) => { videoData.metadata.frameOffset, videoData.metadata.numFrames - 1 ] +} + +export const setForwardPlay = (forwardPlay) => (dispatch) => { + dispatch({ + type: 'setForwardPlay', + forwardPlay: true + }); +}; + +export const setSlowMotion = (slowMotion) => (dispatch) => { + dispatch({ + type: 'setSlowMotion', + slowMotion: true + }); +}; + +export const setPaused = (pause) => (dispatch) => { + dispatch({ + type: 'setPaused', + paused: true + }); +}; + +export const resetPlaybackState = () => dispatch => { + dispatch({ + type: 'resetState', + }) } \ No newline at end of file diff --git a/src/icatcher/icatcher_app/frontend/src/state/VideoDataProvider.jsx b/src/icatcher/icatcher_app/frontend/src/state/VideoDataProvider.jsx index 96a12d1..588e711 100644 --- a/src/icatcher/icatcher_app/frontend/src/state/VideoDataProvider.jsx +++ b/src/icatcher/icatcher_app/frontend/src/state/VideoDataProvider.jsx @@ -72,4 +72,17 @@ export const addFrames = (frames) => dispatch => { numFrames: frames.length } }) -} \ No newline at end of file +} + +export const addAnnotations = (annotations) => dispatch => { + dispatch({ + type: 'setAnnotations', + annotations: annotations + }) +} + +export const resetCurrentVideo = () => dispatch => { + dispatch({ + type: 'resetVideo', + }) +}