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 --- .../app/views/viewer/player/player.container.js | 28 ++++++++++++---------- 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'animism-align/frontend/app/views/viewer/player/player.container.js') diff --git a/animism-align/frontend/app/views/viewer/player/player.container.js b/animism-align/frontend/app/views/viewer/player/player.container.js index 8a23720..a2f999d 100644 --- a/animism-align/frontend/app/views/viewer/player/player.container.js +++ b/animism-align/frontend/app/views/viewer/player/player.container.js @@ -20,25 +20,28 @@ class PlayerContainer extends Component { } setCurrentSection() { - const { audio, sections, currentSection } = this.props + const { audio, sections, currentSection, autoAdvance } = this.props const { play_ts } = audio if (floatInRange(currentSection.start_ts, play_ts, currentSection.end_ts)) { return } - const insideSection = sections.some((section, i) => { - if (floatInRange(section.start_ts, play_ts, section.end_ts)) { - if (currentSection !== section) { - const nextSection = sections[i+1] - actions.viewer.setCurrentSection(section, nextSection) + if (autoAdvance) { + const insideSection = sections.some((section, i) => { + if (floatInRange(section.start_ts, play_ts, section.end_ts)) { + if (currentSection !== section) { + const nextSection = sections[i+1] + actions.viewer.setCurrentSection(section, nextSection) + } + return true } - return true + return false + }) + if (!insideSection) { + actions.viewer.setCurrentSection(sections[sections.length-1], null) } - return false - }) - - if (!insideSection) { - actions.viewer.setCurrentSection(sections[sections.length-1], null) + } else { + actions.viewer.reachedEndOfSection() } } @@ -60,6 +63,7 @@ const mapStateToProps = state => ({ audio: state.audio, sections: state.viewer.sections, currentSection: state.viewer.currentSection, + autoAdvance: state.viewer.autoAdvance, }) export default connect(mapStateToProps)(PlayerContainer) -- cgit v1.2.3-70-g09d2