diff --git a/bin/vidref b/bin/vidref
--- a/bin/vidref
+++ b/bin/vidref
@@ -6,7 +6,7 @@ import sys, logging
sys.path.append(".")
from light9.vidref.main import Main
- # then vidref file cleanup, livevideo ui elements, input picker. find replay dirs correctly. show multiple replays. trash. reorder/pin.
+ # find replay dirs correctly. show multiple replays. trash. reorder/pin.
logging.basicConfig()
diff --git a/light9/vidref/main.py b/light9/vidref/main.py
--- a/light9/vidref/main.py
+++ b/light9/vidref/main.py
@@ -16,7 +16,7 @@ import Image
from threading import Thread
from Queue import Queue
from light9 import networking
-from light9.vidref.replay import ReplayViews
+from light9.vidref.replay import ReplayViews, songDir, takeDir
log = logging.getLogger()
@@ -109,9 +109,7 @@ class VideoRecordSink(gst.Element):
return gst.FLOW_OK
def saveImg(self, position, img, bufferTimestamp):
- outDir = "/tmp/vidref/play-%s-%d" % (
- position['song'].split('://')[-1].replace('/','_'),
- position['started'])
+ outDir = takeDir(songDir(position['song']), position['started'])
outFilename = "%s/%08.03f.jpg" % (outDir, position['t'])
if os.path.exists(outFilename): # we're paused on one time
return
@@ -140,7 +138,9 @@ class Main(object):
mainwin.connect("destroy", gtk.main_quit)
wtree.connect_signals(self)
- self.replayViews = ReplayViews(wtree.get_object("image1"))#"replayScroll"))
+ wtree.get_object("replayPanel").show()
+ rp = wtree.get_object("replayVbox")
+ self.replayViews = ReplayViews(rp)
mainwin.show_all()
self.liveVideoXid = wtree.get_object("vid3").window.xid
diff --git a/light9/vidref/replay.py b/light9/vidref/replay.py
--- a/light9/vidref/replay.py
+++ b/light9/vidref/replay.py
@@ -2,10 +2,15 @@ import os, gtk
from bisect import bisect_left
from decimal import Decimal
-existingDir = "/tmp/vidref/play-_my_proj_light9_show_dance2010_music_01-chorusmix.wav-1276415052"
-existingFrames = sorted([Decimal(f.split('.jpg')[0])
- for f in os.listdir(existingDir)])
+
+def songDir(song):
+ return "/tmp/vidref/play-%s" % song.split('://')[-1].replace('/','_')
+def takeDir(songDir, startTime):
+ """
+ startTime: unix seconds (str ok)
+ """
+ return os.path.join(songDir, str(int(startTime)))
class ReplayViews(object):
"""
@@ -13,13 +18,12 @@ class ReplayViews(object):
these windows to be added
"""
def __init__(self, parent):
- self.out = ReplayView(parent, Replay(existingDir))
- return
- for x in range(1000):
- lab = gtk.Label()
- lab.set_text("hello")
- parent.add_with_viewport(lab)
-
+ # today, parent is the vbox the replay windows should appear in
+ self.parent = parent
+ self.lastSong = None
+
+ self.views = []
+
def update(self, position):
"""
freshen all replay windows. We get called this about every
@@ -27,20 +31,21 @@ class ReplayViews(object):
may be responsible for making new children if we change song
"""
- self.out.updatePic(position)
+ if position['song'] != self.lastSong:
+ self.loadViewsForSong(position['song'])
+ self.lastSong = position['song']
+ for v in self.views:
+ v.updatePic(position)
+
-class Replay(object):
- """
- model for one of the replay widgets
- """
- def __init__(self, sourceDir):
- self.sourceDir = sourceDir
-
- def findClosestFrame(self, t):
- i = bisect_left(existingFrames, Decimal(str(t)))
- if i >= len(existingFrames):
- i = len(existingFrames) - 1
- return os.path.join(existingDir, "%08.03f.jpg" % existingFrames[i])
+ def loadViewsForSong(self, song):
+ # remove previous ones
+
+ takes = os.listdir(songDir(song))
+ for take in takes:
+ td = takeDir(songDir(song), take)
+ rv = ReplayView(self.parent, Replay(td))
+ self.views.append(rv)
class ReplayView(object):
"""
@@ -48,8 +53,15 @@ class ReplayView(object):
"""
def __init__(self, parent, replay):
self.replay = replay
-# self.loadWindwos
- self.picWidget = parent
+
+ # this *should* be a composite widget from glade
+ img = gtk.Image()
+ img.set_size_request(320, 240)
+ parent.pack_end(img, False, False)
+ img.show()
+ self.picWidget = img
+
+# self.picWidget = parent.get_children()[0].get_child()
def updatePic(self, position):
inPic = self.replay.findClosestFrame(position['t']+.25)
@@ -60,3 +72,17 @@ class ReplayView(object):
self.picWidget.queue_draw_area(0,0,320,240)
self.picWidget.get_window().process_updates(True)
+class Replay(object):
+ """
+ model for one of the replay widgets
+ """
+ def __init__(self, takeDir):
+ self.takeDir = takeDir
+
+ def findClosestFrame(self, t):
+ existingFrames = sorted([Decimal(f.split('.jpg')[0])
+ for f in os.listdir(self.takeDir)])
+ i = bisect_left(existingFrames, Decimal(str(t)))
+ if i >= len(existingFrames):
+ i = len(existingFrames) - 1
+ return os.path.join(self.takeDir, "%08.03f.jpg" % existingFrames[i])
diff --git a/light9/vidref/vidref.glade b/light9/vidref/vidref.glade
--- a/light9/vidref/vidref.glade
+++ b/light9/vidref/vidref.glade
@@ -3,6 +3,8 @@
+
+
+
+ True
+
+
+ 320
+ 240
+ True
+ 0
+ out
+ 1.3300000429153442
+
+
+ 320
+ 240
+ True
+ gtk-missing-image
+
+
+
+
+ False
+ 0
+
+
+
+
+ True
+
+
+ True
+
+
+ True
+ Started:
+
+
+ False
+ False
+ 0
+
+
+
+
+ True
+ True
+ False
+ ●
+ 12
+ Sat 14:22:25
+
+
+ False
+ False
+ 1
+
+
+
+
+ False
+ 0
+
+
+
+
+ Enabled
+ True
+ True
+ True
+
+
+ False
+ 1
+
+
+
+
+ Delete
+ True
+ True
+ True
+ image2
+
+
+ False
+ 2
+
+
+
+
+ Pin to top
+ True
+ True
+ False
+ True
+
+
+ False
+ 3
+
+
+
+
+ False
+ 1
+
+
+
+
+
True
gtk-delete