From 87e093760c6d116d9f889493f6be850171a0ae4c Mon Sep 17 00:00:00 2001 From: Andrew Robinson Date: Tue, 29 Apr 2014 21:44:42 +1000 Subject: [PATCH] Playback auto-reset & bugfixes - Auto reset to start/end when playing foward/backward from end/start - bugfixes with speeds other than normal --- sportsreview/aftertouches/main.py | 20 +++++++++++++------- sportsreview/common/framegroup.py | 2 +- sportsreview/settings/settings.py | 6 +++--- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/sportsreview/aftertouches/main.py b/sportsreview/aftertouches/main.py index 7003466..15afd63 100644 --- a/sportsreview/aftertouches/main.py +++ b/sportsreview/aftertouches/main.py @@ -140,13 +140,19 @@ def play(self, speed): if self._openFrameGroup is not None: if speed == 0: self.mainwindow.setStatusMsg("Paused", 1000) - elif speed > 0: + elif speed > 0: # forward + if self._openFrameGroup.index() >= (self._openFrameGroup.getClipEnd() - 1): + self.jumpStart() self.mainwindow.setStatusMsg("Play (%sx)" % speed, 1000) - else: + startTime = time.time() + (self._openFrameGroup[self._openFrameGroup.getClipStart()].timestamp - self._openFrameGroup.current().timestamp) / speed + else: # reverse + if self._openFrameGroup.index() <= self._openFrameGroup.getClipStart(): + self.jumpEnd() self.mainwindow.setStatusMsg("Play reverse (%sx)" % (-speed), 1000) + startTime = time.time() - (self._openFrameGroup.current().timestamp - self._openFrameGroup[self._openFrameGroup.getClipEnd()-1].timestamp) / speed if not self._playingTimer.isActive(): self._playing = speed - self._playStartTime = time.time() + self._playStartTime = startTime self._playingTimer.start(16) #Todo: make this a setting (16 = 62.5 fps (max)) else: pass #TODO: alter start time so it will calculate correctly @@ -209,19 +215,19 @@ def _playFrame(self): lastFrame = None nextFrame = None if self._playing > 0: # playing forward - releaseTimestamp = float(self._openFrameGroup[0].timestamp) + playbackTime + releaseTimestamp = float(self._openFrameGroup[self._openFrameGroup.getClipStart()].timestamp) + playbackTime nextFrame = self._openFrameGroup.peekNext() if self._openFrameGroup.index() >= self._openFrameGroup.getClipEnd(): nextFrame = None while nextFrame is not None and nextFrame.timestamp < releaseTimestamp: lastFrame = self._openFrameGroup.next() nextFrame = self._openFrameGroup.peekNext() - if self._openFrameGroup.index() >= self._openFrameGroup.getClipEnd(): + if self._openFrameGroup.index() >= (self._openFrameGroup.getClipEnd() - 1): nextFrame = None else: # playing reverse - releaseTimestamp = float(self._openFrameGroup[-1].timestamp) + playbackTime + releaseTimestamp = float(self._openFrameGroup[self._openFrameGroup.getClipEnd()-1].timestamp) + playbackTime nextFrame = self._openFrameGroup.peekPrev() - if self._openFrameGroup.index() < self._openFrameGroup.getClipStart(): + if self._openFrameGroup.index() <= self._openFrameGroup.getClipStart(): nextFrame = None while nextFrame is not None and nextFrame.timestamp > releaseTimestamp: lastFrame = self._openFrameGroup.prev() diff --git a/sportsreview/common/framegroup.py b/sportsreview/common/framegroup.py index 096949d..6c04329 100644 --- a/sportsreview/common/framegroup.py +++ b/sportsreview/common/framegroup.py @@ -305,7 +305,7 @@ def clipEnd(self, idx = None): @param idx: int, the index that will be the last frame (exclusive) ''' if idx == None: - self._end = self._current + self._end = self._current + 1 elif idx > 0 and idx <= len(self._frames) and idx > self._start: self._end = idx diff --git a/sportsreview/settings/settings.py b/sportsreview/settings/settings.py index 0d0e6c9..a920d7e 100644 --- a/sportsreview/settings/settings.py +++ b/sportsreview/settings/settings.py @@ -137,13 +137,13 @@ }, ], 'aftertouchesui': { - 'geometry': (1, 39, 1280, 957), - 'mode': 'normal', + 'geometry': (0, 39, 800, 700), + 'mode': 'maximised', 'savegeometry': True, 'savemode': True, }, 'delayanalysisui': { - 'geometry': (77, 54, 960, 768), + 'geometry': (0, 39, 800, 700), 'mode': 'normal', 'savegeometry': True, 'savemode': True,