Update of /cvsroot/freevo/freevo/src/audio
In directory sc8-pr-cvs1:/tmp/cvs-serv5322

Modified Files:
        __init__.py player.py 
Log Message:
expand the <audio> parsing in fxd files

Index: __init__.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/audio/__init__.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** __init__.py 30 Nov 2003 14:41:10 -0000      1.12
--- __init__.py 6 Dec 2003 13:43:34 -0000       1.13
***************
*** 10,13 ****
--- 10,16 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.13  2003/12/06 13:43:34  dischi
+ # expand the <audio> parsing in fxd files
+ #
  # Revision 1.12  2003/11/30 14:41:10  dischi
  # use new Mimetype plugin interface
***************
*** 53,56 ****
--- 56,61 ----
  #endif
  
+ import re
+ 
  import config
  import util
***************
*** 113,116 ****
--- 118,154 ----
  
  
+     def dirinfo(self, diritem):
+         """
+         set informations for a diritem based on the content, etc.
+         """
+         if not diritem.image:
+             images = ()
+             covers = ()
+             files =()
+ 
+             def image_filter(x):
+                 return re.match('.*(jpg|png)$', x, re.IGNORECASE)
+             def cover_filter(x):
+                 return re.search(config.AUDIO_COVER_REGEXP, x, re.IGNORECASE)
+ 
+             # Pick an image if it is the only image in this dir, or it matches
+             # the configurable regexp
+             try:
+                 files = vfs.listdir(diritem.dir)
+             except OSError:
+                 print "oops, os.listdir() error"
+                 traceback.print_exc()
+             images = filter(image_filter, files)
+             image  = None
+             if len(images) == 1:
+                 image = vfs.join(diritem.dir, images[0])
+             elif len(images) > 1:
+                 covers = filter(cover_filter, images)
+                 if covers:
+                     image = vfs.join(diritem.dir, covers[0])
+             diritem.image = image
+ 
+             
+ 
      def fxdhandler(self, fxd, node):
          """
***************
*** 119,144 ****
          <?xml version="1.0" ?>
          <freevo>
!             <audio title="Smoothjazz">
!                 <cover-img>foo.jpg</cover-img>
!                 <mplayer_options></mplayer_options>
!                 <url>http://64.236.34.141:80/stream/1005</url>
  
!                 <info>
!                     <genre>JAZZ</genre>
!                     <description>A nice description</description>
!                 </info>
  
!             </audio>
          </freevo>
          """
          a = AudioItem('', fxd.getattr(None, 'parent', None), scan=False)
          a.name     = fxd.getattr(node, 'title', a.name)
          a.xml_file = fxd.getattr(None, 'filename', '')
          a.image    = fxd.childcontent(node, 'cover-img')
          if a.image:
              a.image = vfs.join(vfs.dirname(a.xml_file), a.image)
  
!         a.mplayer_options = fxd.childcontent(node, 'mplayer_options')
!         a.url = fxd.childcontent(node, 'url')
          fxd.parse_info(fxd.get_children(node, 'info', 1), a)
          fxd.getattr(None, 'items', []).append(a)
--- 157,199 ----
          <?xml version="1.0" ?>
          <freevo>
!           <audio title="Smoothjazz">
!             <cover-img>foo.jpg</cover-img>
!             <mplayer_options></mplayer_options>
!             <player>xine</player>
!             <playlist/>
!             <reconnect/>
!             <url>http://64.236.34.141:80/stream/1005</url>
  
!             <info>
!               <genre>JAZZ</genre>
!               <description>A nice description</description>
!             </info>
  
!           </audio>
          </freevo>
+ 
+         Everything except title and url is optional. If <player> is set,
+         this player will be used (possible xine or mplayer). The tag
+         <playlist/> signals that this url is a playlist (mplayer needs that).
+         <reconnect/> sihnals that the player should reconnect when the
+         connection stopps.
          """
          a = AudioItem('', fxd.getattr(None, 'parent', None), scan=False)
+ 
          a.name     = fxd.getattr(node, 'title', a.name)
          a.xml_file = fxd.getattr(None, 'filename', '')
          a.image    = fxd.childcontent(node, 'cover-img')
+         a.url      = fxd.childcontent(node, 'url')
          if a.image:
              a.image = vfs.join(vfs.dirname(a.xml_file), a.image)
  
!         a.mplayer_options  = fxd.childcontent(node, 'mplayer_options')
!         if fxd.get_children(node, 'player'):
!             a.force_player = fxd.childcontent(node, 'player')
!         if fxd.get_children(node, 'playlist'):
!             a.is_playlist  = True
!         if fxd.get_children(node, 'reconnect'):
!             a.reconnect    = True
!             
          fxd.parse_info(fxd.get_children(node, 'info', 1), a)
          fxd.getattr(None, 'items', []).append(a)

Index: player.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/audio/player.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** player.py   4 Dec 2003 21:48:11 -0000       1.12
--- player.py   6 Dec 2003 13:43:34 -0000       1.13
***************
*** 10,13 ****
--- 10,16 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.13  2003/12/06 13:43:34  dischi
+ # expand the <audio> parsing in fxd files
+ #
  # Revision 1.12  2003/12/04 21:48:11  dischi
  # also add the plugin area
***************
*** 19,50 ****
  # support more than one player
  #
- # Revision 1.9  2003/11/08 13:19:06  dischi
- # add AUDIOCD as plugin type
- #
- # Revision 1.8  2003/10/12 11:01:19  dischi
- # Don't show black screen between selecting and playing an audio file
- #
- # Revision 1.7  2003/09/20 09:44:23  dischi
- # cleanup
- #
- # Revision 1.6  2003/09/15 20:06:02  dischi
- # error handling when mplayer does not start
- #
- # Revision 1.5  2003/08/27 15:27:08  mikeruelle
- # Start of Radio Support
- #
- # Revision 1.4  2003/04/24 19:56:01  dischi
- # comment cleanup for 1.3.2-pre4
- #
- # Revision 1.3  2003/04/22 11:56:45  dischi
- # fixed bug that shows the player again after stopping it
- #
- # Revision 1.2  2003/04/21 18:40:32  dischi
- # use plugin name structure to find the real player
- #
- # Revision 1.1  2003/04/21 13:27:48  dischi
- # o make it possible to hide() the audio player
- # o mplayer is now a plugin, controlled by the PlayerGUI
- #
  # -----------------------------------------------------------------------
  # Freevo - A Home Theater PC framework
--- 22,25 ----
***************
*** 78,83 ****
  
  skin = skin.get_singleton()
! 
! skin.register('player', ('screen', 'title', 'subtitle', 'view', 'info', 'plugin'))
  
  
--- 53,57 ----
  
  skin = skin.get_singleton()
! skin.register('player', ('screen', 'title', 'view', 'info', 'plugin'))
  
  
***************
*** 101,107 ****
          if self.player and self.player.is_playing():
              self.stop()
!             
          if player:
              self.player = player
          else:
              self.possible_player = []
--- 75,82 ----
          if self.player and self.player.is_playing():
              self.stop()
! 
          if player:
              self.player = player
+ 
          else:
              self.possible_player = []
***************
*** 110,113 ****
--- 85,92 ----
                  if config.AUDIO_PREFERED_PLAYER == p.name:
                      rating += 1
+ 
+                 if hasattr(self.item, 'force_player') and p.name == 
self.item.force_player:
+                     rating += 100
+                 
                  self.possible_player.append((rating, p))
              self.possible_player.sort(lambda l, o: -cmp(l[0], o[0]))
***************
*** 185,188 ****
          else:
              self.item.remain = self.item.length - self.item.elapsed
!         skin.draw(('player', self.item))
          return
--- 164,167 ----
          else:
              self.item.remain = self.item.length - self.item.elapsed
!         skin.draw('player', self.item)
          return




-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to