[cvs-annodex] commit (/annodex): annoamp/trunk/annoamp.py
annoamp/trunk/anxplayer.py
scott
nobody at lists.annodex.net
Sun Dec 25 09:24:42 EST 2005
Update of /annodex (new revision 1732)
Modified files:
annoamp/trunk/annoamp.py
annoamp/trunk/anxplayer.py
Log Message:
Modified to work with current gstreamer CVS 12/24/05, >0.10.1.
Fixed handling of taglist.
Still very unstable but works occasionally.
Will work with twism on errors.
Modified: annoamp/trunk/annoamp.py
===================================================================
--- annoamp/trunk/annoamp.py 2005-12-23 01:04:48 UTC (rev 1731)
+++ annoamp/trunk/annoamp.py 2005-12-24 22:24:39 UTC (rev 1732)
@@ -156,9 +156,9 @@
xml.get_widget("link").set_label('No Link')
else:
tree_selection.select_path(playlist.get_path(playlist.iter_nth_child(playlist.iter_nth_child(None,current),chapter)))
- desc = player.chapter_info_list[current][chapter].props.desc
+ desc = player.chapter_info_list[current][chapter].props.description
if desc != None:
- xml.get_widget("description").set_text(player.chapter_info_list[current][chapter].props.desc)
+ xml.get_widget("description").set_text(player.chapter_info_list[current][chapter].props.description)
else:
xml.get_widget("description").set_text("No Description")
link_text = player.chapter_info_list[current][chapter].props.anchor_text
@@ -166,7 +166,7 @@
xml.get_widget("link").set_label(link_text)
else:
xml.get_widget("link").set_label('No Link.')
- img_src = player.chapter_info_list[current][chapter].props.img_src
+ img_src = player.chapter_info_list[current][chapter].props.img_uri
if img_src != None:
try:
img_file = urllib2.urlopen(img_src)
@@ -226,10 +226,10 @@
chooser = gtk.FileChooserDialog("Add a file.", None, gtk.FILE_CHOOSER_ACTION_OPEN, (gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK))
if chooser.run() == gtk.RESPONSE_OK:
file = chooser.get_filename()
- chooser.destroy()
+ chooser.destroy()
load_file(file)
else:
- chooser.destroy()
+ chooser.destroy()
def add_file_p2(filename, info):
global playlist
@@ -274,7 +274,10 @@
files = config.get("DEFAULT","lastOpened").split("\n")
for file in files:
- load_file(file)
+ if os.path.exists(file):
+ load_file(file)
+ else:
+ print "File: " + file + " cannot be found."
def save_settings( player ):
sep = "\n"
Modified: annoamp/trunk/anxplayer.py
===================================================================
--- annoamp/trunk/anxplayer.py 2005-12-23 01:04:48 UTC (rev 1731)
+++ annoamp/trunk/anxplayer.py 2005-12-24 22:24:39 UTC (rev 1732)
@@ -19,7 +19,7 @@
import types
import gobject
import sys
-sys.path.extend(["/usr/local/lib/python2.4/site-packages/gst-0.9"])
+sys.path.extend(["/usr/local/lib/python2.4/site-packages/gst-0.10"])
import gst
def format_time(time):
@@ -64,7 +64,7 @@
self.timeout_id = -1
#Stores the following properties of a clip:
- #anchor_href, anchor_text, desc, empty, end_time, id, img_alt, img_src, meta, start_time, track
+ #anchor_href, anchor_text, description, empty, end_time, id, img_alt, img_uri, meta, start_time, track
self.chapter_info_list = []
self.file_to_index_map = {}
@@ -77,15 +77,15 @@
pass
if time >= 0:
+ #FIXME: new chapters should be handled by the bus call below.
self.update_time_callback(time, self.duration)
-
- if self.pos == -1 and len(self.chapter_info_list[self.current]) != 0 and time > self.chapter_info_list[self.current][0].props.start_time/gst.SECOND: #we are before the first defined clip
+ if self.pos == -1 and len(self.chapter_info_list[self.current]) != 0 and time > self.chapter_info_list[self.current][0].props.start_time/(gst.SECOND*1000000): #we are before the first defined clip
self.pos = 0
self.current_chapter_callback(self.current, 0)
elif self.pos < len(self.chapter_info_list[self.current]) - 1:
- chapter_end_at = self.chapter_info_list[self.current][self.pos].props.end_time/gst.SECOND
+ chapter_end_at = self.chapter_info_list[self.current][self.pos].props.end_time/(gst.SECOND*1000000)
if time >= chapter_end_at: #we hit the end of the chapter
- chapter_next_at = self.chapter_info_list[self.current][self.pos].props.start_time/gst.SECOND
+ chapter_next_at = self.chapter_info_list[self.current][self.pos].props.start_time/(gst.SECOND*1000000)
if time+1 >= chapter_next_at: #the end of this chapter is the start of the next
self.pos += 1
self.current_chapter_callback(self.current, self.pos)
@@ -98,20 +98,21 @@
#self.debug(str(message.type) + "=>" + str(message))
if message.type == gst.MESSAGE_TAG:
self.debug("Tag!")
- def temp (taglist, tag):
+ def temp (tag):
#print taglist.get(tag)
- if type(taglist.get(tag)) == types.LongType or type(taglist.get(tag)) == types.StringType:
- self.debug(taglist.get(tag))
- #FIXME: This isn't how we should bget the type
- elif type(taglist.get(tag)).__name__ == '__main__.GstCmmlTagHead':
- self.debug(type(taglist.get(tag)))
+ if type(tag) == types.LongType or type(tag) == types.StringType:
+ self.debug(tag)
+ #FIXME: This isn't how we should get the type
+ elif type(tag).__name__ == '__main__.GstCmmlTagHead':
+ self.debug(type(tag))
pass
- elif type(taglist.get(tag)).__name__ == '__main__.GstCmmlTagClip':
- self.debug(type(taglist.get(tag)))
- self.debug(taglist.get(tag).get_property("id"))
+ elif type(tag).__name__ == '__main__.GstCmmlTagClip':
+ self.debug(type(tag))
+ self.debug(tag.props.id)
taglist = message.parse_tag()
- taglist.foreach(temp)
+ for key in taglist.keys():
+ temp(taglist[key])
elif message.type == gst.MESSAGE_ERROR:
self.error(message.parse_error())
elif message.type == gst.MESSAGE_EOS:
@@ -141,7 +142,7 @@
def load_file_info(self,filename):
#create a fake pipeline which we'll play, gathering all the tags and storing this information
if filename[-4:]==".anx":
- fake = gst.parse_launch('filesrc name=source ! oggdemux name=demuxer ! cmmldec name=cmml extract_mode=true ! fakesink \n')
+ fake = gst.parse_launch('filesrc name=source ! oggdemux name=demuxer ! cmmldec name=cmml wait-clip-end-time=true ! fakesink \n')
fake_filesrc = fake.get_by_name('source')
fake_filesrc.set_property('location', filename)
@@ -160,29 +161,29 @@
elif message.type == gst.MESSAGE_WARNING:
self.debug("whooops, warning: "+message.parse_warning())
elif message.type == gst.MESSAGE_ERROR:
- self.chapter_info_list[file_to_index_map[filename]] = chapter_info
+ self.chapter_info_list[self.file_to_index_map[filename]] = chapter_info
self.add_file_callback(filename, playlist_info)
self.error(message.parse_error())
fake.set_state(gst.STATE_NULL)
elif message.type == gst.MESSAGE_TAG:
- def temp (taglist, tag, info):
- if type(taglist.get(tag)) == types.LongType or type(taglist.get(tag)) == types.StringType:
- #print taglist.get(tag)
+ def temp (tag, info):
+ if type(tag) == types.LongType or type(tag) == types.StringType:
pass
#FIXME: This isn't how we should be getting the type
- elif type(taglist.get(tag)).__name__ == '__main__.GstCmmlTagHead':
- #print type(taglist.get(tag))
+ elif type(tag).__name__ == '__main__.GstCmmlTagHead':
pass
- elif type(taglist.get(tag)).__name__ == '__main__.GstCmmlTagClip':
- playlist_str = format_time(taglist.get(tag).get_property("start_time")/gst.SECOND)
- if taglist.get(tag).get_property("desc") != None:
- playlist_str += " - " + taglist.get(tag).get_property("desc")
+ elif type(tag).__name__ == '__main__.GstCmmlTagClip':
+ #FIXME remove 1000000s gst.SECOND should be enough.
+ playlist_str = format_time(int(tag.props.start_time/gst.SECOND/1000000))
+ if tag.props.description != None:
+ playlist_str += " - " + tag.props.description
else:
- playlist_str += " - " + taglist.get(tag).get_property("id")
- info[0].append([playlist_str,taglist.get(tag).get_property("start_time")/gst.SECOND]) #playlist info
- info[1].append(taglist.get(tag)) #chapter info
+ playlist_str += " - " + tag.props.id
+ info[0].append([playlist_str,int(tag.props.start_time/gst.SECOND/1000000)]) #playlist info
+ info[1].append(tag) #chapter info
taglist = message.parse_tag()
- taglist.foreach(temp, [playlist_info,chapter_info])
+ for key in taglist.keys():
+ temp(taglist[key], [playlist_info,chapter_info])
return True
bus = fake.get_bus ()
bus.add_watch (bus_call)
--
scott
More information about the cvs-annodex
mailing list