Changeset 2511

Show
Ignore:
Timestamp:
2006-10-02 13:07:52 (2 years ago)
Author:
scott
Message:

Now loads the data from the cmml into the textsource. Some seg faults.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • keystroke/trunk/keystroke.py

    r2510 r2511  
    210210    clip_now = self.current_clip(self.pipeline.query_position(gst.FORMAT_TIME)[0]/gst.MSECOND) 
    211211    if clip_now > 0: 
    212       self.seek(self.times[self.current_track]['start'][clip_now-1],self.times[self.current_track]['start'][clip_now]
     212      self.seek(self.times[self.current_track]['start'][clip_now-1]
    213213       
    214214      #Highlight chapter entry. 
     
    286286    #Push relevant text to overlay. 
    287287    return result 
    288      
     288   
    289289  def push_text_cb(self, accel_group, window, keyval, modifier): 
    290290    self.push_text() 
    291291     
    292   def push_text(self, start=None,end=None): 
    293     #data = self.export_buffer() 
    294     #for clip in data["subtitle-en"]: 
    295       #buf = gst.Buffer (clip[2]) 
    296       #buf.timestamp = to_ms(clip[0])*gst.MSECOND 
    297       #buf.duration = (to_ms(clip[1]) - to_ms(clip[0]))*gst.MSECOND 
    298       #print "time: " + str(buf.timestamp) + " duration: " + str(buf.duration) 
    299       #print self.text_pad.push (buf) 
     292  def push_text(self): 
     293    data = self.export_buffer() 
     294    self.textsource.clear() 
     295    print "PUSH TEXT" 
     296    for clip in data["subtitle-en"]: 
     297      desc = clip[2] 
     298      timestamp = to_ms(clip[0])*gst.MSECOND 
     299      duration = (to_ms(clip[1]) - to_ms(clip[0]))*gst.MSECOND 
     300      self.textsource.append(timestamp, duration, desc) 
    300301    pass 
    301302       
     
    598599      self.progress.props.fraction = x/total_clips 
    599600    self.pipeline_duration = self.pipeline.query_duration(gst.FORMAT_TIME)[0]/gst.MSECOND 
     601    self.push_text() 
    600602    if (end_time!="" and to_ms(end_time) < self.pipeline_duration-3*60*1000) or to_ms(start_time) < self.pipeline_duration-4*60*1000: #If last clip is towards end, skip and play from the beginning.  If not go to the last clip. 
    601603      if end_time!="": 
     
    649651    elif message.type == gst.MESSAGE_STATE_CHANGED and (message.parse_state_changed()[0]==gst.STATE_PAUSED or message.parse_state_changed()[0]==gst.STATE_PLAYING) and message.parse_state_changed()[2]==gst.STATE_VOID_PENDING and message.src == self.pipeline: 
    650652      print message.parse_state_changed() 
    651       self.push_text() 
     653      #self.push_text() 
    652654    else: 
    653655      #print "Unhandled: " + str(message.type) 
  • keystroke/trunk/textsrc.py

    r2510 r2511  
    3131    ) 
    3232   
    33   data = [[0*gst.MSECOND, 1958*gst.MSECOND,"...if you want to hold it."], [1958*gst.MSECOND,3627*gst.MSECOND,"Oh you gotta... Does this pick you up as well?"]
     33  data = [
    3434  current_index = 0 
    3535   
     
    5050      self.current_index += 1 
    5151      return gst.FLOW_OK, buf 
     52    elif len(self.data)>0: 
     53      buf = gst.Buffer(" ") 
     54      buf.timestamp = self.data[-1][0]+self.data[-1][1] 
     55      buf.duration = 9999999*gst.SECOND # A really long time.  (FIXME) 
     56      return gst.FLOW_OK, buf 
    5257    else: 
    5358      buf = gst.Buffer(" ") 
    54       buf.timestamp = self.data[-1][0]+self.data[-1][1] 
     59      buf.timestamp = 0*gst.SECOND 
    5560      buf.duration = 9999999*gst.SECOND # A really long time.  (FIXME) 
    5661      return gst.FLOW_OK, buf 
     
    6368  def do_is_seekable(self): 
    6469    return True 
     70     
     71  def append(self, timestamp, duration, desc): 
     72    self.data.append([timestamp, duration, desc]) 
     73    return 
     74     
     75  def clear(self): 
     76    self.data = [] 
     77    return