Skip to content

Commit

Permalink
Playback auto-reset & bugfixes
Browse files Browse the repository at this point in the history
- Auto reset to start/end when playing foward/backward from end/start
- bugfixes with speeds other than normal
  • Loading branch information
andrewjrobinson committed Apr 29, 2014
1 parent 5f89e37 commit 87e0937
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
20 changes: 13 additions & 7 deletions sportsreview/aftertouches/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion sportsreview/common/framegroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions sportsreview/settings/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 87e0937

Please sign in to comment.