~ubuntu-branches/ubuntu/oneiric/emesene/oneiric-proposed

« back to all changes in this revision

Viewing changes to plugins_base/currentSong/Audacious.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:
48
48
        if self.iface:
49
49
            return self.iface.Status() == "playing" #Note: self.iface.Playing() returns True even if it's paused
50
50
        else:
51
 
            return commands.getoutput("audtool playback-status") == "playing"
 
51
            return commands.getoutput("audtool2 playback-status") == "playing"
 
52
 
 
53
    # In this plugin we have to override isRunning and getStatus.
 
54
    # Audacious in old versions didn't use D-Bus and used an external
 
55
    # program called audtool2 to comunicate. Now newer versions can use D-Bus.
 
56
    # We support both.
 
57
    
 
58
    def isRunning( self ):
 
59
        if self.iface:
 
60
            return True
 
61
        if len(commands.getoutput("audtool2 version")) > 0:
 
62
            return True
 
63
        return False
52
64
        
53
65
    def getStatus( self ):
54
66
        '''check if everything is OK to start the plugin
55
67
        return a tuple whith a boolean and a message
56
68
        if OK -> ( True , 'some message' )
57
69
        else -> ( False , 'error message' )'''
58
 
        
 
70
 
59
71
        if os.name != 'posix':
60
 
            return ( False, _( 'This plugin only works in posix systems' ) ) #no posix here
61
 
   
62
 
        if not self.is_on_path( 'audtool' ) and not self.iface:
63
 
            return ( False, _( 'audtool is not on the path and you don\'t have dbus enabled.' ) ) #no audtool here
 
72
            return ( False, _( 'This plugin only works in posix systems' ) )
 
73
 
 
74
        # We can't work if we don't have D-Bus and there is no audtool2
 
75
        if self.bus == None and not self.is_on_path( 'audtool2' ):
 
76
            return ( False, _( 'audtool2 is not on the path and you don\'t have dbus enabled.' ) )
64
77
        
65
 
        return ( True, 'Ok' ) #ok, run baby!
 
78
        return ( True, 'Ok' )
66
79
 
67
80
    def getCurrentSong( self ):
68
81
        if not self.iface:
69
82
            if self.isPlaying():
70
 
                song = commands.getoutput( "audtool current-song" )
 
83
                song = commands.getoutput( "audtool2 current-song" )
71
84
                fsong = '\\0Music\\01\\0' + song + '\\0\\0'
72
85
                return fsong
73
86
            else:
80
93
            if self.isPlaying():
81
94
                songPosition = self.iface.Position()
82
95
                artist = self.iface.SongTuple(songPosition, "artist") 
83
 
                title = self.iface.SongTuple(songPosition, "title") 
84
 
                album = self.iface.SongTuple(songPosition, "album") 
85
 
                if self.artist != artist or self.title != title or self.album != album:
86
 
                    self.artist = artist
87
 
                    self.title = title
88
 
                    self.album = album
89
 
                    self.filename = self.iface.SongTitle(songPosition)
90
 
                    return True
91
 
            else: # Just stopped, paused, ... set the data as empty strings
92
 
                if self.artist != "" or self.title != "" or self.album != "":
93
 
                    self.artist = ""
94
 
                    self.title = ""
95
 
                    self.album = ""
96
 
                    self.filename = ""
97
 
                    return True
98
 
        
99
 
        
 
96
                title = self.iface.SongTuple(songPosition, "title") 
 
97
                album = self.iface.SongTuple(songPosition, "album") 
 
98
                if self.artist != artist or self.title != title or self.album != album:
 
99
                    self.artist = artist
 
100
                    self.title = title
 
101
                    self.album = album
 
102
                    self.filename = self.iface.SongTitle(songPosition)
 
103
                    return True
 
104
            else: # Just stopped, paused, ... set the data as empty strings
 
105
                if self.artist != "" or self.title != "" or self.album != "":
 
106
                    self.artist = ""
 
107
                    self.title = ""
 
108
                    self.album = ""
 
109
                    self.filename = ""
 
110
                    return True
100
111
        elif self.isPlaying():
101
112
            currentSong = self.getCurrentSong()
102
113
            if self.playingNow != currentSong: