[cvs-annodex] commit (/annodex): annoamp/trunk/annoamp.py

jkivlighn nobody at lists.annodex.net
Wed Nov 2 15:56:57 EST 2005


Update of /annodex (new revision 1598)

Modified files:
   annoamp/trunk/annoamp.py

Log Message:
- Better method of determining when a new clip is hit.  It just looks at the start time of the 
  next clip during every update_time() call, rather than looping over all the times and 
  figuring out where the current time fits in
- osssink->alsasink



Modified: annoamp/trunk/annoamp.py
===================================================================
--- annoamp/trunk/annoamp.py	2005-11-02 00:50:10 UTC (rev 1597)
+++ annoamp/trunk/annoamp.py	2005-11-02 04:56:55 UTC (rev 1598)
@@ -36,7 +36,7 @@
         
         self.bin = gst.parse_launch('filesrc name=source ! oggdemux name=demuxer \n' + 
                            'demuxer. ! queue ! cmmldec name=cmml ! fakesink \n' +
-                           'demuxer. ! queue ! vorbisdec name=decoder ! audioconvert ! osssink')
+                           'demuxer. ! queue ! vorbisdec name=decoder ! audioconvert ! alsasink')
         self.bin.error = pipe_error
         '''
 
@@ -76,17 +76,18 @@
     def update_time(self):
         time = -1
         try:
-            time = self.bin.query_position(gst.FORMAT_TIME)[0]
+            time = self.bin.query_position(gst.FORMAT_TIME)[0]/gst.SECOND
         except:
             pass
 
         if time >= 0:
-            self.update_time_callback(time/gst.SECOND, self.duration)
+            self.update_time_callback(time, self.duration)
             
-            chapter = self.chapter_at(time/gst.SECOND)
-            if self.pos != chapter: #we hit a new chapter
-                self.current_chapter_callback(chapter)
-                self.pos = chapter
+            if self.pos < playlist.iter_n_children(None) - 1:
+                next_chapter_at = playlist.get_value(self.playlist.iter_nth_child(None,self.pos+1), 1)
+                if time >= next_chapter_at: #we hit a new chapter
+                    self.pos += 1
+                    self.current_chapter_callback(self.pos)
 
         if self.bin.get_state()[1] == gst.STATE_PAUSED:
             return False
@@ -135,6 +136,7 @@
         self.playlist = playlist
         self.pos = -1
 
+        #create a fake pipeline which we'll play, gathering all the tags and storing this information
         fake = gst.parse_launch('filesrc name=source ! oggdemux name=demuxer ! cmmldec name=cmml ! fakesink \n')
         fake_filesrc = fake.get_by_name('source')
         fake_filesrc.set_property('location', filename)
@@ -173,7 +175,7 @@
         result = self.bin.set_state(gst.STATE_PAUSED)
         
     def seek(self,location):
-        event = gst.event_new_seek(1.0, gst.FORMAT_TIME, 1, gst.SEEK_TYPE_SET, gst.SECOND*location, gst.SEEK_TYPE_NONE, 0);
+        event = gst.event_new_seek(1.0, gst.FORMAT_TIME, gst.SEEK_FLAG_FLUSH, gst.SEEK_TYPE_SET, gst.SECOND*location, gst.SEEK_TYPE_NONE, 0);
         print "%s" % event
         result = self.bin.send_event(event)
 


-- 
jkivlighn



More information about the cvs-annodex mailing list