Update of /cvsroot/freevo/freevo/src/audio
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1689

Modified Files:
        audiodiskitem.py audioitem.py player.py 
Log Message:
replace player.get_singleton() with audioplayer()

Index: audioitem.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/audio/audioitem.py,v
retrieving revision 1.62
retrieving revision 1.63
diff -C2 -d -r1.62 -r1.63
*** audioitem.py        10 Sep 2004 19:50:06 -0000      1.62
--- audioitem.py        13 Sep 2004 19:35:35 -0000      1.63
***************
*** 5,8 ****
--- 5,11 ----
  # $Id$
  #
+ # This file contains an item used for audio files. It handles all actions
+ # possible for an audio item (right now only 'play')
+ #
  # Notes:
  # Todo:        
***************
*** 10,13 ****
--- 13,19 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.63  2004/09/13 19:35:35  dischi
+ # replace player.get_singleton() with audioplayer()
+ #
  # Revision 1.62  2004/09/10 19:50:06  outlyer
  # Copy fix from 1.5.1 to HEAD branch.
***************
*** 55,69 ****
  # ----------------------------------------------------------------------- */
  
  
  import os
  import re
- import traceback
  
  import config
- import player
- 
  from item import MediaItem
  from event import *
  
  
  class AudioItem(MediaItem):
--- 61,90 ----
  # ----------------------------------------------------------------------- */
  
+ __all__ = [ 'AudioItem' ]
  
+ # Python imports
  import os
  import re
  
+ # Freevo imports
  import config
  from item import MediaItem
  from event import *
  
+ from player import *
+ 
+ 
+ def _image_filter(x):
+     """
+     filter used to find cover images
+     """
+     return re.match('.*(jpg|png)$', x, re.IGNORECASE)
+ 
+ def _cover_filter(x):
+     """
+     filter used to find cover images
+     """
+     return re.search(config.AUDIO_COVER_REGEXP, x, re.IGNORECASE)
+ 
  
  class AudioItem(MediaItem):
***************
*** 71,88 ****
      This is the common class to get information about audiofiles.
      """
-     
      def __init__(self, url, parent, name=None, scan=True):
          MediaItem.__init__(self, 'audio', parent)
- 
          self.set_url(url, info=scan)
- 
          if name:
              self.name   = name
- 
          self.start      = 0
          self.elapsed    = 0
          self.remain     = 0
          self.pause      = 0
- 
          self.mplayer_options = ''
              
--- 92,104 ----
***************
*** 99,106 ****
              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
--- 115,118 ----
***************
*** 110,121 ****
                  files = os.listdir(dirname)
              except OSError:
!                 print "oops, os.listdir() error"
!                 traceback.print_exc()
!             images = filter(image_filter, files)
              image = None
              if len(images) == 1:
                  image = os.path.join(dirname, images[0])
              elif len(images) > 1:
!                 covers = filter(cover_filter, images)
                  if covers:
                      image = os.path.join(dirname, covers[0])
--- 122,132 ----
                  files = os.listdir(dirname)
              except OSError:
!                 _debug_('os.listdir() error', 0)
!             images = filter(_image_filter, files)
              image = None
              if len(images) == 1:
                  image = os.path.join(dirname, images[0])
              elif len(images) > 1:
!                 covers = filter(_cover_filter, images)
                  if covers:
                      image = os.path.join(dirname, covers[0])
***************
*** 129,137 ****
          if mode == 'date':
              if self.filename:
!                 return u'%s%s' % (os.stat(self.filename).st_ctime, 
Unicode(self.filename))
          if mode == 'advanced':
              # sort by track number
              try:
!                 return '%s %0.3i-%s' % (self['discs'],int(self['trackno']), 
Unicode(self.url))
              except ValueError:
                  return '%s-%s' % (Unicode(self['trackno']), Unicode(self.url))
--- 140,150 ----
          if mode == 'date':
              if self.filename:
!                 return u'%s%s' % (os.stat(self.filename).st_ctime,
!                                   Unicode(self.filename))
          if mode == 'advanced':
              # sort by track number
              try:
!                 return '%s %0.3i-%s' % (self['discs'], int(self['trackno']),
!                                         Unicode(self.url))
              except ValueError:
                  return '%s-%s' % (Unicode(self['trackno']), Unicode(self.url))
***************
*** 167,172 ****
  
     
-     # ----------------------------------------------------------------------------
- 
      def actions(self):
          """
--- 180,183 ----
***************
*** 182,187 ****
          self.parent.current_item = self
          self.elapsed = 0
! 
!         player.get_singleton().play(self)
  
  
--- 193,197 ----
          self.parent.current_item = self
          self.elapsed = 0
!         audioplayer().play(self)
  
  
***************
*** 190,192 ****
          Stop the current playing
          """
!         player.get_singleton().stop()
--- 200,202 ----
          Stop the current playing
          """
!         audioplayer().stop()

Index: player.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/audio/player.py,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** player.py   25 Aug 2004 12:51:44 -0000      1.28
--- player.py   13 Sep 2004 19:35:35 -0000      1.29
***************
*** 1,8 ****
  # -*- coding: iso-8859-1 -*-
  # -----------------------------------------------------------------------
! # player.py - the Freevo audio player GUI
  # -----------------------------------------------------------------------
  # $Id$
  #
  # Notes:
  # Todo:        
--- 1,13 ----
  # -*- coding: iso-8859-1 -*-
  # -----------------------------------------------------------------------
! # player.py - the Freevo audio player
  # -----------------------------------------------------------------------
  # $Id$
  #
+ # This module provides the auido player. It will use one of the registered
+ # player plugins to play the audio item (e.g. audio.mplayer)
+ #
+ # You can access the player by calling audioplayer()
+ #
  # Notes:
  # Todo:        
***************
*** 10,13 ****
--- 15,21 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.29  2004/09/13 19:35:35  dischi
+ # replace player.get_singleton() with audioplayer()
+ #
  # Revision 1.28  2004/08/25 12:51:44  dischi
  # moved Application for eventhandler into extra dir for future templates
***************
*** 25,29 ****
  # make the player an "Application"
  #
- #
  # -----------------------------------------------------------------------
  # Freevo - A Home Theater PC framework
--- 33,36 ----
***************
*** 47,51 ****
--- 54,60 ----
  # ----------------------------------------------------------------------- */
  
+ __all__ = [ 'audioplayer' ]
  
+ # Freevo imports
  import config
  import gui
***************
*** 55,76 ****
  from application import Application
  
! _player_ = None
  
! def get_singleton():
      """
      return the global audio player object
      """
!     global _player_
!     if not _player_:
!         _player_ = PlayerGUI()
!     return _player_
  
  
! class PlayerGUI(Application):
      """
      basic object to handle the different player
      """
      def __init__(self):
!         Application.__init__(self, 'mplayer', 'audio', False, True)
          self.player     = None
          self.running    = False
--- 64,85 ----
  from application import Application
  
! _singleton = None
  
! def audioplayer():
      """
      return the global audio player object
      """
!     global _singleton
!     if _singleton == None:
!         _singleton = AudioPlayer()
!     return _singleton
  
  
! class AudioPlayer(Application):
      """
      basic object to handle the different player
      """
      def __init__(self):
!         Application.__init__(self, 'audioplayer', 'audio', False, True)
          self.player     = None
          self.running    = False
***************
*** 78,82 ****
  
          # register player to the skin
!         self.draw_engine = gui.AreaHandler('player', ('screen', 'title', 'view', 
'info'))
  
      def play(self, item, player=None):
--- 87,93 ----
  
          # register player to the skin
!         areas = ('screen', 'title', 'view', 'info')
!         self.draw_engine = gui.AreaHandler('player', areas)
! 
  
      def play(self, item, player=None):
***************
*** 99,106 ****
                  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]))
--- 110,116 ----
                  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]))

Index: audiodiskitem.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/audio/audiodiskitem.py,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -d -r1.30 -r1.31
*** audiodiskitem.py    10 Jul 2004 12:33:37 -0000      1.30
--- audiodiskitem.py    13 Sep 2004 19:35:26 -0000      1.31
***************
*** 5,8 ****
--- 5,11 ----
  # $Id$
  #
+ # This file handles and item for an audio cd. When selected it will either
+ # play the whole disc or show a menu with all items. 
+ #
  # Notes:
  # Todo:        
***************
*** 10,13 ****
--- 13,19 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.31  2004/09/13 19:35:26  dischi
+ # replace player.get_singleton() with audioplayer()
+ #
  # Revision 1.30  2004/07/10 12:33:37  dischi
  # header cleanup
***************
*** 37,46 ****
  # ----------------------------------------------------------------------- */
  
  
  import config
  import menu
- import os
  
- from item import Item
  from audioitem import AudioItem
  from playlist import Playlist
--- 43,55 ----
  # ----------------------------------------------------------------------- */
  
+ __all__ = [ 'AudioDiskItem' ]
+ 
+ # Python imports
+ import os
  
+ # Freevo imports
  import config
  import menu
  
  from audioitem import AudioItem
  from playlist import Playlist
***************
*** 51,55 ****
      class for handling audio disks
      """
!     def __init__(self, disc_id, parent, devicename = None, display_type = None):
  
          Playlist.__init__(self, parent=parent)
--- 60,65 ----
      class for handling audio disks
      """
!     def __init__(self, disc_id, parent, devicename = None,
!                  display_type = None):
  
          Playlist.__init__(self, parent=parent)
***************
*** 91,98 ****
              title=self.info['tracks'][i]['title']
              item = AudioItem('cdda://%d' % (i+1), self, title, scan=False)
- 
-             # XXX FIXME: set also all the other infos here if AudioInfo
-             # XXX will be based on mmpython
-             #item.set_info('', self.name, title, i+1, self.disc_id[1], '')
              item.info = self.info['tracks'][i]
              item.length = item.info['length']
--- 101,104 ----
***************
*** 112,116 ****
  
          # random playlist (only active for audio)
!         if 'audio' in config.DIRECTORY_ADD_RANDOM_PLAYLIST and len(play_items) > 1:
              pl = Playlist(_('Random playlist'), play_items, self, random=True)
              pl.autoplay = True
--- 118,123 ----
  
          # random playlist (only active for audio)
!         if 'audio' in config.DIRECTORY_ADD_RANDOM_PLAYLIST and \
!                len(play_items) > 1:
              pl = Playlist(_('Random playlist'), play_items, self, random=True)
              pl.autoplay = True



-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM. 
Deadline: Sept. 13. Go here: http://sf.net/ppc_contest.php
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to