~jconti/ubuntu/precise/emesene/fix-956422

« back to all changes in this revision

Viewing changes to plugins_base/currentSong/Gmusicbrowser.py

  • Committer: Bazaar Package Importer
  • Author(s): Devid Antonio Filoni
  • Date: 2010-04-14 01:33:51 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20100414013351-r2icbt5gs4ai71j8
Tags: 1.6.1-0ubuntu1
* New upstream release (LP: #562646).
* Fix missing-debian-source-format lintian warning.
* Refresh 20_dont_build_own_libmimic.patch patch.
* Bump Standards-Version to 3.8.4.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#   This file is part of emesene.
 
2
#
 
3
#    Emesene is free software; you can redistribute it and/or modify
 
4
#    it under the terms of the GNU General Public License as published by
 
5
#    the Free Software Foundation; either version 2 of the License, or
 
6
#    (at your option) any later version.
 
7
#
 
8
#    emesene is distributed in the hope that it will be useful,
 
9
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
#    GNU General Public License for more details.
 
12
#
 
13
#    You should have received a copy of the GNU General Public License
 
14
#    along with emesene; if not, write to the Free Software
 
15
#    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
16
#
 
17
#    Original version by Quentin Sculo
 
18
#    http://squentin.free.fr/gmusicbrowser/dokuwiki/doku.php?id=third_party_apps:emesene
 
19
 
 
20
VERSION = '0.2'
 
21
IFACE_NAME = 'org.gmusicbrowser'
 
22
IFACE_PATH = '/org/gmusicbrowser'
 
23
 
 
24
import CurrentSong
 
25
 
 
26
class Gmusicbrowser ( CurrentSong.DbusBase ):
 
27
    '''Gmusicbrowser Interface'''
 
28
 
 
29
    def __init__( self ):
 
30
        CurrentSong.DbusBase.__init__( self, IFACE_NAME, self.setInterface )
 
31
 
 
32
        try: self.iface
 
33
        except: self.iface = None
 
34
 
 
35
    def setInterface( self ):
 
36
        self.iface = self.bus.get_object( IFACE_NAME, IFACE_PATH )
 
37
 
 
38
    def isPlaying(self):
 
39
        if self.isRunning():
 
40
            return bool( self.iface.Playing() )
 
41
        return False
 
42
 
 
43
    def check(self):
 
44
        if not self.isRunning():
 
45
            return False
 
46
 
 
47
        info = { 'title':'', 'album':'', 'artist':'' }
 
48
 
 
49
        if self.isPlaying():
 
50
            info = dict(self.iface.CurrentSong())
 
51
        
 
52
        if info['title'] != self.title or info['album'] != self.album or info['artist'] != self.artist:
 
53
            self.title = info['title']
 
54
            self.album = info['album']
 
55
            self.artist = info['artist']
 
56
            return True        
 
57
        return False
 
58
 
 
59
    def getCoverPath( self ):
 
60
        if self.isRunning() and len(self.album) > 0:
 
61
            return self.iface.GetAlbumCover(self.album)
 
62
        return None
 
63