From da76513e9d5c2a0a1660ac321f126d7c79bf6392 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 26 Aug 2020 17:55:10 +0200 Subject: adjusting timing, pause at end of section --- .../frontend/app/views/viewer/viewer.actions.js | 25 +++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'animism-align/frontend/app/views/viewer/viewer.actions.js') diff --git a/animism-align/frontend/app/views/viewer/viewer.actions.js b/animism-align/frontend/app/views/viewer/viewer.actions.js index 5d6775f..097f01b 100644 --- a/animism-align/frontend/app/views/viewer/viewer.actions.js +++ b/animism-align/frontend/app/views/viewer/viewer.actions.js @@ -156,10 +156,6 @@ const makeFullscreenEvent = (index, annotation) => { return event } -export const setCurrentSection = (currentSection, nextSection) => dispatch => { - dispatch({ type: types.viewer.set_current_section, currentSection, nextSection }) -} - export const setNavStyle = color => dispatch => { dispatch({ type: types.viewer.set_nav_style, color }) } @@ -176,13 +172,32 @@ export const toggleComponent = key => dispatch => { dispatch({ type: types.viewer.toggle_component, key, value: !store.getState().viewer[key] }) } +const getNextSection = section => { + const { sections } = store.getState().viewer + if (section.index === sections.length - 1) { + return null + } + return sections[section.index + 1] +} + +export const reachedEndOfSection = () => dispatch => { + actions.audio.pause() + dispatch({ type: types.viewer.reached_end_of_section }) +} + +export const setCurrentSection = (currentSection, nextSection) => dispatch => { + dispatch({ type: types.viewer.set_current_section, currentSection, nextSection }) +} + export const seekToSection = section => dispatch => { + actions.viewer.setCurrentSection(section, getNextSection(section)) actions.audio.seek(section.start_ts) actions.audio.play() actions.viewer.hideComponent('nav') } -export const seekToMediaItem = mediaItem => dispatch => { +export const seekToMediaItem = (section, mediaItem) => dispatch => { + actions.viewer.setCurrentSection(section, getNextSection(section)) actions.audio.seek(mediaItem.start_ts) actions.audio.play() actions.viewer.hideComponent('nav') -- cgit v1.2.3-70-g09d2