rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
os.system(convert_cmd1 % (pict.props.name, tmp_pict))
os.system(convert_cmd1 % (os.path.join(self.album.dir, pict.props.name), tmp_pict))
def __check_picts(self, chapter): print " converting picts.." convert_cmd1 = "convert -resize 704x576! '%s' '%s'" convert_cmd2 = "convert -resize 704x576 '%s' '%s'" convert_cmd3 = "convert -border %dx0 -bordercolor black '%s' '%s'"
os.system(convert_cmd2 % (pict.props.name, tmp_pict))
os.system(convert_cmd2 % (os.path.join(self.album.dir, pict.props.name), tmp_pict))
def __check_picts(self, chapter): print " converting picts.." convert_cmd1 = "convert -resize 704x576! '%s' '%s'" convert_cmd2 = "convert -resize 704x576 '%s' '%s'" convert_cmd3 = "convert -border %dx0 -bordercolor black '%s' '%s'"
for pict in chapter.picts:
for pict in self.album.picts: if pict.props.vcd_chapter != chapter.name or not pict.props.vcd_included: continue
def __rm_picts_links(self, chapter): duration = 5*25 # 5 seconds * 25 fps i = 0 for pict in chapter.picts: for j in range(0, duration): slink = os.path.join(chapter.mpeg_dir, "pict-%s-%04d.jpg" % (chapter.esc_name, i*duration+j)) os.unlink(slink) pass i = i + 1 pass pass
print " creating video %s" % chapter.props.video_name
print " creating video %s" % chapter.video_name
def __check_video(self, chapter): print " creating video %s" % chapter.props.video_name yuv_cmd = "jpeg2yuv -v 0 -f 25 -I p -j '%s' " mpeg_cmd = "mpeg2enc -v 0 -a 2 -n p -f 4 -o '%s'" if os.access(chapter.props.video_name, os.F_OK): print " video %s already exists" % chapter.props.video_name return
if os.access(chapter.props.video_name, os.F_OK): print " video %s already exists" % chapter.props.video_name
if not chapter.remake and os.access(chapter.video_name, os.F_OK): print " video %s already exists" % chapter.video_name
def __check_video(self, chapter): print " creating video %s" % chapter.props.video_name yuv_cmd = "jpeg2yuv -v 0 -f 25 -I p -j '%s' " mpeg_cmd = "mpeg2enc -v 0 -a 2 -n p -f 4 -o '%s'" if os.access(chapter.props.video_name, os.F_OK): print " video %s already exists" % chapter.props.video_name return
mpeg_cmd % chapter.props.video_name)
mpeg_cmd % chapter.video_name)
def __check_video(self, chapter): print " creating video %s" % chapter.props.video_name yuv_cmd = "jpeg2yuv -v 0 -f 25 -I p -j '%s' " mpeg_cmd = "mpeg2enc -v 0 -a 2 -n p -f 4 -o '%s'" if os.access(chapter.props.video_name, os.F_OK): print " video %s already exists" % chapter.props.video_name return
if os.access(chapter.props.mpg_name, os.F_OK): print "mpeg %s already exists" % chapter.props.mpg_name
if not chapter.remake and os.access(chapter.mpg_name, os.F_OK): print "mpeg %s already exists" % chapter.mpg_name
def __check_mpg(self, chapter): mplex_cmd = "mplex -v 0 -f 4 -o '%s' '%s' '%s'" if os.access(chapter.props.mpg_name, os.F_OK): print "mpeg %s already exists" % chapter.props.mpg_name return
os.system(mplex_cmd % (chapter.props.mpg_name, chapter.props.video_name, chapter.props.sound_name))
os.system(mplex_cmd % (chapter.mpg_name, chapter.video_name, chapter.sound_name))
def __check_mpg(self, chapter): mplex_cmd = "mplex -v 0 -f 4 -o '%s' '%s' '%s'" if os.access(chapter.props.mpg_name, os.F_OK): print "mpeg %s already exists" % chapter.props.mpg_name return
print "creating mpeg for chapter " + chapter.props.name + "..."
print "creating mpeg for chapter " + chapter.name + "..."
def __create_mpeg(self, chapter): print "creating mpeg for chapter " + chapter.props.name + "..."
for row in self.tv_vcd_chapters.get_model(): xml.write(' <sequence-item src="%s" id="sequence-%02d"/>\n' % (row[1].props.mpg_name, i))
for chpt in self.album.props.vcd_chapters: xml.write(' <sequence-item src="%s" id="sequence-%02d"/>\n' % (chpt.mpg_name, i))
def on_btn_build_cd_clicked(self, widget): print "build CD" xml = open("/tmp/videocd.xml", "w")
chapter = model.get_value(iter, self.VCD_CLMN_CHTR) chapter.props.mp3_name = self.file_chooser_dialog.get_filename() self.ent_music.set_text(chapter.props.mp3_name)
if model.iter_depth(iter) == 1: iter = model.iter_parent(iter) pass name = model.get_value(iter, self.VCD_CLMN_NAME) chapter = self.__find_chapter(name) chapter.mp3_name = self.file_chooser_dialog.get_filename() self.ent_music.set_text(chapter.mp3_name)
def on_btn_choose_music_clicked(self, widget): self.file_chooser_dialog.set_action(gtk.FILE_CHOOSER_ACTION_OPEN) self.file_chooser_dialog.set_title("Choose background music") response = self.file_chooser_dialog.run() self.file_chooser_dialog.hide() if response == gtk.RESPONSE_OK: model, iter = self.tv_vcd_chapters.get_...
chapter = model.get_value(iter, self.VCD_CLMN_CHTR) if os.access(chapter.props.mpg_name, os.F_OK): os.system("vlc '%s'" % chapter.props.mpg_name)
pict = model.get_value(iter, self.VCD_CLMN_PICT) if pict: chapter = self.__find_chapter(pict.props.vcd_chapter) else: chapter = self.__find_chapter(model.get_value(iter, self.VCD_CLMN_NAME)) pass if os.access(chapter.mpg_name, os.F_OK): os.system("vlc '%s'" % chapter.mpg_name)
def on_btn_chapters_play_clicked(self, widget): model, iter = self.tv_vcd_chapters.get_selection().get_selected() if iter == None: return chapter = model.get_value(iter, self.VCD_CLMN_CHTR) if os.access(chapter.props.mpg_name, os.F_OK): os.system("vlc '%s'" % chapter.props.mpg_name) pass pass
if os.access(chapter.props.sound_name, os.F_OK): os.system("vlc '%s'" % chapter.props.sound_name) elif os.access(chapter.props.mp3_name, os.F_OK): os.system("vlc '%s'" % chapter.props.mp3_name)
if os.access(chapter.sound_name, os.F_OK): os.system("vlc '%s'" % chapter.sound_name) elif os.access(chapter.mp3_name, os.F_OK): os.system("vlc '%s'" % chapter.mp3_name)
def on_btn_sound_play_clicked(self, widget): model, iter = self.tv_vcd_chapters.get_selection().get_selected() if iter == None: return chapter = model.get_value(iter, self.VCD_CLMN_CHTR) if os.access(chapter.props.sound_name, os.F_OK): os.system("vlc '%s'" % chapter.props.sound_name) elif os.access(chapter.props.mp3_na...
pass
print "on_tv_vcd_chapters_cursor_changed" model, iter = self.tv_vcd_chapters.get_selection().get_selected() pict = model.get_value(iter, self.VCD_CLMN_PICT) if pict: mp3_name = self.__find_chapter(pict.props.vcd_chapter).mp3_name else: mp3_name = self.__find_chapter(model.get_value(iter, self.VCD_CLMN_NAME)).mp3_name p...
def on_tv_vcd_chapters_cursor_changed(self, widget): #print "on_tv_vcd_chapters_cursor_changed" #model, iter = self.tv_vcd_chapters.get_selection().get_selected() #chapter = model.get_value(iter, self.VCD_CLMN_CHTR) #self.ent_music.set_text(chapter.props.mp3_name) pass
chapter = self.gofoto.albumCollection.get_chapter(selection_data.data) if chapter != None: name = chapter.album.props.name + " / " + chapter.props.name self.tv_vcd_chapters.get_model().append(None, [name, chapter]) pass
print "received:" + str(selection_data.data) model = self.tv_vcd_chapters.get_model() src_row = model[selection_data.data] dest_row = model[dest_path] if dest_row[self.VCD_CLMN_PICT] != None or src_row[self.VCD_CLMN_PICT] == None: return 0 pict = src_row[self.VCD_CLMN_PICT] model.append(dest_row.iter, [pict, src_row[se...
def on_tv_vcd_chapters_drag_data_received(self, widget, context, x, y, selection_data, info, timestamp): print "on_tv_vcd_chapters_drag_data_received" dest = self.tv_vcd_chapters.get_dest_row_at_pos(x, y) print "dest "+str(dest) context.finish(gtk.TRUE, gtk.FALSE, timestamp) chapter = self.gofoto.albumCollection.get_ch...
print "Removed chapter had no children"
print "Removed chapter '%s' had no children" % name self.album.props.vcd_chapters.remove(chpt)
def on_remove_chapter_activate(self, widget): model, iter = self.tv_vcd_chapters.get_selection().get_selected() if not iter: return
for chpt in self.album.props.vcd_chapters: if chpt.name == name: self.album.props.vcd_chapters.remove(chpt) break pass
self.album.props.vcd_chapters.remove(chpt)
def on_remove_chapter_activate(self, widget): model, iter = self.tv_vcd_chapters.get_selection().get_selected() if not iter: return
class Properties: def save(self, doc, xml_base): xml = doc.createElement("props") xml_base.appendChild(xml) for key in self.__dict__.keys(): type = self.__dict__[key].__class__.__name__ if type == "int": node_key = doc.createElement(key) xml.appendChild(node_key) node_key.setAttribute("type", "int") node_key.setAttrib...
def appdir(path): return os.path.join(os.path.dirname(sys.argv[0]), path)
self.props = Properties()
self.props = properties.Properties()
def __init__(self, album, arg): self.album = album self.props = Properties()
pict_xml = doc.createElement("pict") xml.appendChild(pict_xml) self.props.save(doc, pict_xml)
self.props.save(doc, xml, "pict")
def save(self, doc, xml): pict_xml = doc.createElement("pict") xml.appendChild(pict_xml) self.props.save(doc, pict_xml) pass
self.props = Properties()
self.props = properties.Properties()
def __init__(self, album, chpt_xml=None, dir=None): self.album = album self.props = Properties() self.picts = []
self.props = Properties()
self.props = properties.Properties()
def __init__(self, dir, alb_xml=None): self.dir = os.path.abspath(dir) self.props = Properties() self.picts = []
self.props.save(doc, alb_xml)
self.props.save(doc, alb_xml, "album")
def save(self): doc = xml.dom.minidom.Document()
log.info("Album saved")
log.info("Album %s saved" % self.props.name)
def save(self): doc = xml.dom.minidom.Document()
album = Album(dir, alb_xml)
props_xml = alb_xml.getElementsByTagName("album")[0] album = Album(dir, props_xml)
def append_album(self, dir, doc): if self.get_album_by_dir(dir): return # album alb_xml = doc.getElementsByTagName("gofoto")[0] album = Album(dir, alb_xml) self.albums.append(album) # picts for pict_xml in alb_xml.getElementsByTagName("pict"): album.picts.append(Pict(album, pict_xml)) pass
__implements__ = ITALExpressionErrorInfo
implements(ITALExpressionErrorInfo)
def length(self): """Get the length of the iterator sequence >>> context = Context(ExpressionEngine(), {}) >>> it = Iterator('foo', ("apple", "pear", "orange"), context) >>> it.length() 3
__implements__ = ITALExpressionCompiler
implements(ITALExpressionCompiler)
def __init__(self, err, position=(None, None)): if isinstance(err, Exception): self.type = err.__class__ self.value = err else: self.type = err self.value = None self.lineno = position[0] self.offset = position[1]
__implements__ = ITALExpressionEngine
implements(ITALExpressionEngine)
def getCompilerError(self): return CompilerError
"""Return whether the length of the sequence
"""Return the length of the sequence
def length(): """Return whether the length of the sequence
self._done = 1
self._done = True
def __init__(self, name, seq, context): """Construct an iterator
self._done = 0
self._done = False
def __init__(self, name, seq, context): """Construct an iterator
>>> int(bool(it.next())) 1
>>> bool(it.next()) True
def next(self): """Advance the iterator, if possible.
>>> int(bool(it.next())) 0
>>> bool(it.next()) False
def next(self): """Advance the iterator, if possible.
>>> int(bool(it.next())) 1 >>> int(bool(it.next())) 1 >>> int(bool(it.next())) 1 >>> int(bool(it.next())) 0
>>> bool(it.next()) True >>> bool(it.next()) True >>> bool(it.next()) True >>> bool(it.next()) False
def next(self): """Advance the iterator, if possible.
return 0
return False
def next(self): """Advance the iterator, if possible.
self._done = 1 self._last = 1
self._done = True self._last = True
def next(self): """Advance the iterator, if possible.
return 1
return True
def next(self): """Advance the iterator, if possible.
>>> int(bool(it.next())) 1 >>> int(bool(it.even())) 0 >>> int(bool(it.next())) 1 >>> int(bool(it.even())) 1 >>> int(bool(it.next())) 1 >>> int(bool(it.even())) 0
>>> it.next() True >>> it.even() False >>> it.next() True >>> it.even() True >>> it.next() True >>> it.even() False
def even(self): """Test whether the position is even
>>> int(bool(it.next())) 1 >>> int(bool(it.odd())) 1 >>> int(bool(it.next())) 1 >>> int(bool(it.odd())) 0 >>> int(bool(it.next())) 1 >>> int(bool(it.odd())) 1 """ return self._nextIndex % 2
>>> it.next() True >>> it.odd() True >>> it.next() True >>> it.odd() False >>> it.next() True >>> it.odd() True """ return bool(self._nextIndex % 2)
def odd(self): """Test whether the position is odd
>>> int(bool(it.next())) 1
>>> it.next() True
def parity(self): """Return 'odd' or 'even' depending on the position's parity
>>> int(bool(it.next())) 1
>>> it.next() True
def letter(self, base=ord('a'), radix=26): """Get the iterator position as a lower-case letter
>>> int(bool(it.next())) 1
>>> it.next() True
def Letter(self): """Get the iterator position as an upper-case letter
>>> int(bool(it.next())) 1
>>> it.next() True
def Roman(self, rnvalues=( (1000,'M'),(900,'CM'),(500,'D'),(400,'CD'), (100,'C'),(90,'XC'),(50,'L'),(40,'XL'), (10,'X'),(9,'IX'),(5,'V'),(4,'IV'),(1,'I')) ): """Get the iterator position as an upper-case roman numeral
>>> int(bool(it.next())) 1
>>> it.next() True
def roman(self): """Get the iterator position as a lower-case roman numeral
>>> int(bool(it.next())) 1 >>> int(bool(it.start())) 1 >>> int(bool(it.next())) 1 >>> int(bool(it.start())) 0 >>> int(bool(it.next())) 1 >>> int(bool(it.start())) 0
>>> it.next() True >>> it.start() True >>> it.next() True >>> it.start() False >>> it.next() True >>> it.start() False
def start(self): """Test whether the position is the first position
>>> int(bool(it.start())) 0 >>> int(bool(it.next())) 0 >>> int(bool(it.start())) 0
>>> it.start() False >>> it.next() False >>> it.start() False
def start(self): """Test whether the position is the first position
>>> int(bool(it.next())) 1 >>> int(bool(it.end())) 0 >>> int(bool(it.next())) 1 >>> int(bool(it.end())) 0 >>> int(bool(it.next())) 1 >>> int(bool(it.end())) 1
>>> it.next() True >>> it.end() False >>> it.next() True >>> it.end() False >>> it.next() True >>> it.end() True
def end(self): """Test whether the position is the last position
>>> int(bool(it.end())) 0 >>> int(bool(it.next())) 0 >>> int(bool(it.end())) 0
>>> it.end() False >>> it.next() False >>> it.end() False
def end(self): """Test whether the position is the last position
>>> int(bool(it.next())) 1
>>> it.next() True
def item(self): """Get the iterator value
if text is _default or text is None:
if text is self.getDefault() or text is None:
def evaluateText(self, expr): text = self.evaluate(expr) if text is _default or text is None: return text return unicode(text)
self.assertEqual(expr(self.context), self.engine)
self.assertEqual(expr(self.context), self.context)
def testSetEngine(self): expr = self.engine.compile('adapterTest/namespace:engine') self.assertEqual(expr(self.context), self.engine)
ROOT.SgErrorIgnoreLevel = 3000
ROOT.gErrorIgnoreLevel = 3000
def test2ClassOverloads( self ): """Test functions overloaded on void* and non-existing classes."""
for var in "CCSHARED","GCCSHARED":
for var in "CCSHARED","GCCSHARED","CFLAGS","OPT":
def disable_fPIC(): """Disable -fPIC in the c compiler command line. Some unix setups need -fPIC turned off to successfully compile video/libavcodec/i386/dsputil_mmx.c (and other files). Distutils gets the flag by parsing python2.3/config/Makefile and storing the result in a cache. This function is a hack that depen...
def _getVStreamParams( self, vindex, vparams, r ):
def _getStreamParams( self, vindex, aindex, vparams, aparams, r ):
def _getVStreamParams( self, vindex, vparams, r ): # Decode one video frame and 1 audio frame to get stream data vDec= None for d in r: try: # Demux file into streams if d[ 0 ]== vindex: if not vDec: vDec= vcodec.Decoder( vparams ) vfr= vDec.decode( d[ 1 ] ) if vfr and vfr.data: if vfr.aspect_ratio> .0: self.pictureSiz...
vDec= None
vDec= aDec= None
def _getVStreamParams( self, vindex, vparams, r ): # Decode one video frame and 1 audio frame to get stream data vDec= None for d in r: try: # Demux file into streams if d[ 0 ]== vindex: if not vDec: vDec= vcodec.Decoder( vparams ) vfr= vDec.decode( d[ 1 ] ) if vfr and vfr.data: if vfr.aspect_ratio> .0: self.pictureSiz...
break
if aindex== -1 or aDec: break elif d[ 0 ]== aindex: if not aDec: aDec= acodec.Decoder( aparams ) afr= aDec.decode( d[ 1 ] ) if afr and afr.data: self.aBitRate= afr.bitrate self.aSampleRate= afr.sample_rate self.aChannels= afr.channels if vindex== -1 or vDec: break
def _getVStreamParams( self, vindex, vparams, r ): # Decode one video frame and 1 audio frame to get stream data vDec= None for d in r: try: # Demux file into streams if d[ 0 ]== vindex: if not vDec: vDec= vcodec.Decoder( vparams ) vfr= vDec.decode( d[ 1 ] ) if vfr and vfr.data: if vfr.aspect_ratio> .0: self.pictureSiz...
if self.snd== None:
if self.aBitRate== -1:
def _processAudioFrame( self, d ): # Decode audio frame afr= self.ac.decode( d[ 1 ] ) if afr: # See if we have to set up the sound if self.snd== None: self.aBitRate= afr.bitrate self.aSampleRate= afr.sample_rate self.aChannels= afr.channels try: # Hardcoded S16 ( 16 bit signed ) for now #print 'Opening sound', afr.samp...
self.snd= sound.Output( afr.sample_rate, afr.channels, sound.AFMT_S16_LE, self.audioCard )
self.snd= sound.Output( self.aSampleRate, self.aChannels, sound.AFMT_S16_LE, self.audioCard )
def _processAudioFrame( self, d ): # Decode audio frame afr= self.ac.decode( d[ 1 ] ) if afr: # See if we have to set up the sound if self.snd== None: self.aBitRate= afr.bitrate self.aSampleRate= afr.sample_rate self.aChannels= afr.channels try: # Hardcoded S16 ( 16 bit signed ) for now #print 'Opening sound', afr.samp...
if self.startPos: self.seekTo( self.startPos )
def _readerLoop( self ): f= None try: while self.exitFlag== 0: if self.playingFile== None: time.sleep( 0.01 ) continue self.length= self.frameNum= -1 # Initialize demuxer and read small portion of the file to have more info on the format self.clearError() if type( self.playingFile ) in ( str, unicode ): try: f= open( ...
if self.vindex>= 0: self._getVStreamParams( self.vindex, streams[ self.vindex ], r )
as= vs= None if self.aindex!= -1: as= streams[ self.aindex ] if self.vindex!= -1: vs= streams[ self.vindex ] self._getStreamParams( self.vindex, self.aindex, vs, as, r )
def _readerLoop( self ): f= None try: while self.exitFlag== 0: if self.playingFile== None: time.sleep( 0.01 ) continue self.length= self.frameNum= -1 # Initialize demuxer and read small portion of the file to have more info on the format self.clearError() if type( self.playingFile ) in ( str, unicode ): try: f= open( ...
if self.endPos and self._getPTS()* 1000> self.endPos:
if self.endPos and self._getPTS()> self.endPos:
def _readerLoop( self ): f= None try: while self.exitFlag== 0: if self.playingFile== None: time.sleep( 0.01 ) continue self.length= self.frameNum= -1 # Initialize demuxer and read small portion of the file to have more info on the format self.clearError() if type( self.playingFile ) in ( str, unicode ): try: f= open( ...
def loadIcon( self, paramName, default ):
def loadIcon( self, paramName, default, alpha= -1 ):
def loadIcon( self, paramName, default ): icons= self.getParam( paramName, default ) icons1= None if type( icons )== str: icons1= pygame.image.load( 'icons/'+ icons ) elif type( icons )== list or type( icons )== tuple: icons1= map( lambda x: pygame.image.load( 'icons/'+ x ), icons ) return icons1
font= pygame.font.SysFont( fontName, int( fontSize ) )
font= pygame.font.Font( 'icons/'+ fontName+ '.ttf', int( fontSize ) )
def loadFont( self, paramName ): fontName= self.getParam( paramName, DEFAULT_FONT ) fontSize= self.getParam( paramName+ 'Size', DEFAULT_FONT_SIZE ) font= pygame.font.SysFont( fontName, int( fontSize ) ) if self.getParam( paramName+ 'Bold', 'no' )== 'yes': font.set_bold( 1 ) fontColor= self.getParamList( paramName+ 'Co...
text= self.font[ 0 ].render( item[ 'caption' ], 1 , self.font[ 1 ] )
text1= self.font[ 0 ].render( item[ 'caption' ], 1 , self.font[ 1 ] ) text= self.font[ 0 ].render( item[ 'caption' ], 1 , (0,0,0) ) text.blit( text1, (-1,-1))
def drawItem( self, itemPos, isFocused ): item= self.itemsWrapper.items()[ itemPos ] # Find out whether it is a directory or file text= self.font[ 0 ].render( item[ 'caption' ], 1 , self.font[ 1 ] ) # Center text into rect resItem= [] if isFocused== 1: resItem.append( ( self.stripeIcon, LEFT_C ) ) resItem.append( ( t...
self.navIcons= self.loadIcon( 'navIcons', ( 'up_0.gif', 'down_0.gif' ) )
self.navIcons= self.loadIcon( 'navIcons', NAV_ICONS )
def __init__( self, rect, params, renderClass ): """ __init__( rect, renderClass, eventQueue ) -> Constructor for the class. renderClass - is a class which knows how to display certain type of files control will display default icons and behaviors when None or not specified. eventQueue - allows to process some items in...
"""
Initiate process of displaying the data """
def init( self, itemsWrapper, activeItem= 0 ): """ """ # Initiate process of displaying the data itemsWrapper.init() self.renderClass.setItemsWrapper( itemsWrapper ) self.itemsWrapper= itemsWrapper self.lastActiveItem= -1 self.setItems( self.activeItem ) self.moveTo( activeItem )
"""
Return effective window height excluding header and footer areas """ i= 0
def getEffectiveHeight( self ): """ """ if self.scrollFlag: return self.rect[ 3 ]- self.scrollFont[ 0 ].get_height() else: return self.rect[ 3 ]
return self.rect[ 3 ]- self.scrollFont[ 0 ].get_height() else: return self.rect[ 3 ]
i+= self.scrollFont[ 0 ].get_linesize() if self.headerIcon: i+= self.headerFont[ 0 ].get_linesize() return self.rect[ 3 ]- i
def getEffectiveHeight( self ): """ """ if self.scrollFlag: return self.rect[ 3 ]- self.scrollFont[ 0 ].get_height() else: return self.rect[ 3 ]
return int( self.rect[ 2 ] / self.getRenderer().getItemSize()[ 0 ] )
return int( self.getEffectiveWidth() / self.getRenderer().getItemSize()[ 0 ] )
def getItemsPerRow( self ): """ Calculate number of items per row """ return int( self.rect[ 2 ] / self.getRenderer().getItemSize()[ 0 ] )
return int( self.rect[ 3 ] / self.getRenderer().getItemSize()[ 1 ] )
return int( self.getEffectiveHeight() / self.getRenderer().getItemSize()[ 1 ] )
def getItemsPerColumn( self ): """ Calculate number of items per column """ return int( self.rect[ 3 ] / self.getRenderer().getItemSize()[ 1 ] )
getActiveItem() -> ( index ) return active item as an index
return active item as an index
def getActiveItem( self ): """ getActiveItem() -> ( index ) return active item as an index """ return self.activeItem
def showItem( self, i, pos ):
def setHeader( self, title ): i= self.getEffectiveWidth() size= self.headerFont[ 0 ].size( title ) while size[ 0 ]> i: title= title[ 1: ] size= self.headerFont[ 0 ].size( title ) self.headerIcon= self.headerFont[ 0 ].render( title, 1, self.headerFont[ 1 ] ) j= self.headerIcon.get_width() self.headerIcon= (( self.heade...
def showItem( self, i, pos ): item= self.getRenderer().drawItem( i, self.activeItem== i and self.isActive() ) return self.adjustPos( item, pos )
def showLine( self, yPos, start ): """ _showLine( yPos ) -> ( success )
def renderLine( self, yPos, start ): """ showLine( yPos, startIndex ) -> ( currentIndex, items )
def showLine( self, yPos, start ): """ _showLine( yPos ) -> ( success ) Shows line based either on top of current items or at the bottom. Returns whether it was successfull. """ # Get drawer class renderClass= self.getRenderer() # Find out which item we should start from and how many of them would be displayed itemSiz...
itemsPerLine= self.getItemsPerRow()
itemsPerRow= self.getItemsPerRow()
def showLine( self, yPos, start ): """ _showLine( yPos ) -> ( success ) Shows line based either on top of current items or at the bottom. Returns whether it was successfull. """ # Get drawer class renderClass= self.getRenderer() # Find out which item we should start from and how many of them would be displayed itemSiz...
for i in xrange( start, start+ itemsPerLine ):
for i in xrange( start, start+ itemsPerRow ):
def showLine( self, yPos, start ): """ _showLine( yPos ) -> ( success ) Shows line based either on top of current items or at the bottom. Returns whether it was successfull. """ # Get drawer class renderClass= self.getRenderer() # Find out which item we should start from and how many of them would be displayed itemSiz...
res+= self.showItem( i, ( xPos, yPos ) )
res+= self.renderItem( i, ( xPos, yPos ) )
def showLine( self, yPos, start ): """ _showLine( yPos ) -> ( success ) Shows line based either on top of current items or at the bottom. Returns whether it was successfull. """ # Get drawer class renderClass= self.getRenderer() # Find out which item we should start from and how many of them would be displayed itemSiz...
def showStatusLine( self ):
def renderHeader( self ): """ renderHeader() -> yOffs, header Returns header if any. """ if self.headerIcon: return self.headerIcon[ 0 ][ 0 ].get_height(), list( self.headerIcon ) else: return 0, [] def renderStatusLine( self ): """ showStatusLine() -> statusLineItems Returns status items that been rendered if any....
def showStatusLine( self ): if self.isActive()== 0: return [] text= self.scrollFont[ 0 ].render( '%d of %d' % ( self.activeItem+ 1, self.getItemsCount() ), 1, self.scrollFont[ 1 ] ) totalWidth= self.navIcons[ 0 ].get_width()* 2+ text.get_width()+ 30 yPos= self.rect[ 3 ]- text.get_height()- 5 res= [ ( text, ( self.rect...
return self.adjustPos( self.renderMessage( 'Empty' ), self.rect[ :2 ] ) yPos= 0 i= self.startFrom res= [] while i< self.getItemsCount() and yPos+ itemSize[ 1 ]< self.getEffectiveHeight(): j, resTmp= self.showLine( yPos, i ) i+= j res+= resTmp yPos+= itemSize[ 1 ] if ( self.activeItem< self.startFrom or self.activeI...
res+= self.renderCustomMessage( EMPTY ) else: iInitial= yPos i= self.startFrom while i< self.getItemsCount() and yPos- iInitial+ itemSize[ 1 ]<= self.getEffectiveHeight(): j, resTmp= self.renderLine( yPos, i ) i+= j res+= resTmp yPos+= itemSize[ 1 ] if ( self.activeItem< self.startFrom or self.activeItem> self.getLa...
def render( self ): # Start showing the menu if there was a change if self.visible== 0: return [] itemSize= self.getRenderer().getItemSize() # Render only message when list is empty if self.getItemsCount()== 0: self.activeItem= -1 return self.adjustPos( self.renderMessage( 'Empty' ), self.rect[ :2 ] ) # Show items o...
class MenuWrapper: def __init__( self, items ): self.menuItems= items def items( self ): return self.menuItems import pygame resolution = 640,480 pygame.init() screen = pygame.display.set_mode(resolution) rect= ( 210,120,210,200 ) params= { 'font': 'Arial.ttf', 'fontSize': '20', 'fontColor': '89,150,255', 'scroll': 'n...
print 'This module cannot run. It should be used in pymedia library only.'
def render( self ): # Start showing the menu if there was a change if self.visible== 0: return [] itemSize= self.getRenderer().getItemSize() # Render only message when list is empty if self.getItemsCount()== 0: self.activeItem= -1 return self.adjustPos( self.renderMessage( 'Empty' ), self.rect[ :2 ] ) # Show items o...
self.err= []
def __init__( self, callback= None ): """ Create new Player instance. In case if you want to play video you have to supply the callback class instance which will get video data and will be able to display it properly ( onVideoReady() call ). For audio data the playback is done through the pymedia.sound.Output object. B...
self.err.append( sys.exc_info()[1] )
self.err.append( sys.exc_info() )
def _initAudio( self, params ): try: # Reset audio stream self._resetAudio() # Initializing audio codec self.ac= acodec.Decoder( params ) except: self.err.append( sys.exc_info()[1] )
else: lStreams= filter( lambda x: x and ( x[ 'length' ]> 0 ), dm.streams ) if len( lStreams ): self.length= max( [ x[ 'length' ] for x in lStreams ] ) else: self.length= -1
def _getStreamLength( self, format, dm, f, fr ): # Demux frames from the beginning and from the end and get the PTS diff if not dm.hasHeader(): startPTS= -1 for d in fr: if d[ 3 ]> 0: startPTS= d[ 3 ] / 90 break
self.err.append( sys.exc_info()[1] )
self.err.append( sys.exc_info() )
def _getVStreamParams( self, vindex, vparams, r ): # Decode one video frame and 1 audio frame to get stream data vDec= None for d in r: try: # Demux file into streams if d[ 0 ]== vindex: if not vDec: vDec= vcodec.Decoder( vparams ) vfr= vDec.decode( d[ 1 ] ) if vfr and vfr.data: if vfr.aspect_ratio> .0: self.pictureSiz...
self.snd.setVolume( self.volume )
def _processAudioFrame( self, d ): # Decode audio frame afr= self.ac.decode( d[ 1 ] ) if afr: # See if we have to set up the sound if self.snd== None: self.aBitRate= afr.bitrate self.aSampleRate= afr.sample_rate self.aChannels= afr.channels try: # Hardcoded S16 ( 16 bit signed ) for now self.snd= sound.Output( afr.samp...
self.err.append( sys.exc_info()[1] )
self.err.append( sys.exc_info() )
def _processAudioFrame( self, d ): # Decode audio frame afr= self.ac.decode( d[ 1 ] ) if afr: # See if we have to set up the sound if self.snd== None: self.aBitRate= afr.bitrate self.aSampleRate= afr.sample_rate self.aChannels= afr.channels try: # Hardcoded S16 ( 16 bit signed ) for now self.snd= sound.Output( afr.samp...
self.aDecodedFrames.append( afr )
data= afr.data if len( data )> self.maxBufSize: data= str( data ) while len( data )> self.maxBufSize: chunk= data[ : self.maxBufSize ] data= data[ self.maxBufSize: ] self.aDecodedFrames.append( ( chunk, afr.sample_rate, afr.channels ) ) self.aDecodedFrames.append( ( data, afr.sample_rate, afr.channels ) )
def _processAudioFrame( self, d ): # Decode audio frame afr= self.ac.decode( d[ 1 ] ) if afr: # See if we have to set up the sound if self.snd== None: self.aBitRate= afr.bitrate self.aSampleRate= afr.sample_rate self.aChannels= afr.channels try: # Hardcoded S16 ( 16 bit signed ) for now self.snd= sound.Output( afr.samp...
if len( self.aDecodedFrames[ 0 ].data )> snd.getSpace() and self.vindex!= -1:
if len( self.aDecodedFrames[ 0 ][ 0 ] )> snd.getSpace() and self.vindex!= -1:
def _processAudio( self ): snd= self.snd while len( self.aDecodedFrames ) and snd: # See if we can play sound chunk without clashing with the video frame if len( self.aDecodedFrames[ 0 ].data )> snd.getSpace() and self.vindex!= -1: break #print 'player SOUND LEFT:', self.snd.getLeft(), self.snd.getSpace(), self.isPlay...
afr= self.aDecodedFrames.pop(0) s= afr.data
data, sampleRate, channnels= self.aDecodedFrames.pop(0)
def _processAudio( self ): snd= self.snd while len( self.aDecodedFrames ) and snd: # See if we can play sound chunk without clashing with the video frame if len( self.aDecodedFrames[ 0 ].data )> snd.getSpace() and self.vindex!= -1: break #print 'player SOUND LEFT:', self.snd.getLeft(), self.snd.getSpace(), self.isPlay...
afr1= self.callback.onAudioReady( afr ) if afr1: s= afr1
data1= self.callback.onAudioReady( data, sampleRate, channnels ) if data1: data= data1
def _processAudio( self ): snd= self.snd while len( self.aDecodedFrames ) and snd: # See if we can play sound chunk without clashing with the video frame if len( self.aDecodedFrames[ 0 ].data )> snd.getSpace() and self.vindex!= -1: break #print 'player SOUND LEFT:', self.snd.getLeft(), self.snd.getSpace(), self.isPlay...
s= self.resampler.resample( s ) snd.play( s )
data= self.resampler.resample( data ) snd.play( data )
def _processAudio( self ): snd= self.snd while len( self.aDecodedFrames ) and snd: # See if we can play sound chunk without clashing with the video frame if len( self.aDecodedFrames[ 0 ].data )> snd.getSpace() and self.vindex!= -1: break #print 'player SOUND LEFT:', self.snd.getLeft(), self.snd.getSpace(), self.isPlay...
volume = [ 0..255 ]
volume = [ 0..65535 ]
def setVolume( self, volume ): """ Set volume for the media track to play volume = [ 0..255 ] """ self.volume= volume if self.snd: self.snd.setVolume( self.volume )
if self.snd: self.snd.setVolume( self.volume )
conns= sound.Mixer().getControls() if len( conns ): conns[ 0 ][ 'control' ].setValue( self.volume )
def setVolume( self, volume ): """ Set volume for the media track to play volume = [ 0..255 ] """ self.volume= volume if self.snd: self.snd.setVolume( self.volume )
Get volume for the playing media track """ if self.snd: return self.snd.getVolume()
Get volume for the playing media track 0..65535 """ conns= sound.Mixer().getControls() if len( conns ): return conns[ 0 ][ 'control' ].getValue() return 0
def getVolume( self ): """ Get volume for the playing media track """ if self.snd: return self.snd.getVolume()
return self.aBitRate
if self.aindex!= -1: return self.aBitRate return 0 def getBitRate( self ): """ Get bitrate for the full stream """ return self.getABitRate()+ self.vBitRate
def getABitRate( self ): """ Get bitrate for the audio stream if present """ return self.aBitRate
return self._getPTS()
if self.isPlaying(): return self._getPTS() return 0
def getPosition( self ): """ Returns current position for the media """ return self._getPTS()
self.err= []
self.clearError()
def _readerLoop( self ): f= None try: while self.exitFlag== 0: if self.playingFile== None: time.sleep( 0.01 ) continue self.length= self.frameNum= -1 # Initialize demuxer and read small portion of the file to have more info on the format self.err= [] if type( self.playingFile ) in ( str, unicode ): try: f= open( self....
self.err.append( sys.exc_info()[1] )
self.err.append( sys.exc_info() )
def _readerLoop( self ): f= None try: while self.exitFlag== 0: if self.playingFile== None: time.sleep( 0.01 ) continue self.length= self.frameNum= -1 # Initialize demuxer and read small portion of the file to have more info on the format self.err= [] if type( self.playingFile ) in ( str, unicode ): try: f= open( self....
s= f.read( FILE_CHUNK ) r= dm.parse( s )
def _readerLoop( self ): f= None try: while self.exitFlag== 0: if self.playingFile== None: time.sleep( 0.01 ) continue self.length= self.frameNum= -1 # Initialize demuxer and read small portion of the file to have more info on the format self.err= [] if type( self.playingFile ) in ( str, unicode ): try: f= open( self....
f.seek( self.seek* self.getABitRate()/ 8, 0 )
if self.length> 0 and self.fileSize> 0: f.seek( ( float( self.seek ) / self.length )* self.fileSize, 0 ) else: f.seek( self.seek* self.getBitRate()/ 8, 0 )
def _readerLoop( self ): f= None try: while self.exitFlag== 0: if self.playingFile== None: time.sleep( 0.01 ) continue self.length= self.frameNum= -1 # Initialize demuxer and read small portion of the file to have more info on the format self.err= [] if type( self.playingFile ) in ( str, unicode ): try: f= open( self....
self.aDelta= seek
def _readerLoop( self ): f= None try: while self.exitFlag== 0: if self.playingFile== None: time.sleep( 0.01 ) continue self.length= self.frameNum= -1 # Initialize demuxer and read small portion of the file to have more info on the format self.err= [] if type( self.playingFile ) in ( str, unicode ): try: f= open( self....