Changeset - f85304fdc975
[Not reviewed]
default
0 1 0
drewp@bigasterisk.com - 15 years ago 2010-06-22 02:27:30
drewp@bigasterisk.com
cleanup no-song logic
Ignore-this: e03fc8ed94bbda94c63ae947ab4939bd
1 file changed with 1 insertions and 4 deletions:
0 comments (0 inline, 0 general)
light9/vidref/replay.py
Show inline comments
 
@@ -17,67 +17,64 @@ def takeDir(songDir, startTime):
 
    return os.path.join(songDir, str(int(startTime)))
 

	
 
class ReplayViews(object):
 
    """
 
    the whole list of replay windows. parent is the scrolling area for
 
    these windows to be added
 
    """
 
    def __init__(self, parent):
 
        # today, parent is the vbox the replay windows should appear in
 
        self.parent = parent
 
        self.lastStart = None
 

	
 
        self.views = []
 
     
 
    def update(self, position):
 
        """
 
        freshen all replay windows. We get called this about every
 
        time there's a new live video frame.
 

	
 
        Calls loadViewsForSong if we change songs, or even if we just
 
        restart the playback of the current song (since there could be
 
        a new replay view)
 
        """
 
        t1 = time.time()
 
        if position.get('started') != self.lastStart:
 
        if position.get('started') != self.lastStart and position['song']:
 
            self.loadViewsForSong(position['song'])
 
            self.lastStart = position['started']
 
        for v in self.views:
 
            v.updatePic(position)
 
        log.debug("update %s views in %.2fms",
 
                  len(self.views), (time.time() - t1) * 1000)
 

	
 
    def loadViewsForSong(self, song):
 
        """
 
        replace previous views, and cleanup short ones
 
        """
 
        for v in self.views:
 
            v.destroy()
 
        self.views[:] = []
 

	
 
        if not song:
 
            return
 
        
 
        d = songDir(song)
 
        try:
 
            takes = sorted(t for t in os.listdir(d) if t.isdigit())
 
        except OSError:
 
            return
 
        
 
        for take in takes:
 
            td = takeDir(songDir(song), take)
 
            r = Replay(td)
 
            if r.tooShort():
 
                log.warn("cleaning up %s; too short" % r.takeDir)
 
                r.deleteDir()
 
                continue
 
            rv = ReplayView(self.parent, r)
 
            self.views.append(rv)
 

	
 
class ReplayView(object):
 
    """
 
    one of the replay widgets
 
    """
 
    def __init__(self, parent, replay):
 
        self.replay = replay
 
        self.enabled = True
 
        self.showingPic = None
0 comments (0 inline, 0 general)