1 # -*- coding: utf-8 -*-
3 # ****************************************************************************
4 # Copyright (c) 2008 INdT/Fucapi.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Lesser General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 # ============================================================================
19 # Project Name : PC Remote
20 # Author : Jonatas Isvi
21 # Email : jonatas.nona@gmail.com
26 # Description : Amarok Player
27 # ============================================================================
32 from playlist import Playlist
37 return commands.getoutput(command)
39 # starts the amarok player application
43 # close the amarok player application
45 shell('dcop amarok player stop')
46 pid = shell('pidof amarokapp')
47 shell('kill -9 %s' % pid)
49 # verifies if the amarok is running
51 pid = shell('pidof amarokapp')
60 Define all states and functions of amarok player.
61 This class will build to support PCRemote Player,
62 receiving messages from any devices with a bluetooth
66 # some importants variables
68 self.amarok = pydcop.anyAppCalled("amarok")
69 self.playlist = Playlist(self.amarok.playlist.saveCurrentPlaylist())
72 # refresh playlist, accessing the Playlist class instance
73 def refresh_playlist(self):
74 self.playlist = Playlist(self.amarok.playlist.saveCurrentPlaylist())
77 # get all songs of playlist
81 # show current song, acessing the Playlist class instance
82 def current_song(self):
85 # verifies if this amarok app is running
87 aux = pydcop.anyAppCalled("amarok")
93 # verifies if this amarok app is playing and update the
94 # Playlist with current song
96 if not self.amarok.player.isPlaying() == 'true':
97 self.playlist.update(self.amarok.playlist.getActiveIndex() + 1,\
98 self.amarok.player.title(), \
99 self.amarok.player.artist(), \
100 self.amarok.player.path(), \
101 "." + self.amarok.player.type(), \
107 # get the players name
111 # send audio files to the N810 device
112 def audio_file_properties(self, index=None):
113 audiofile = (self.playlist.song_filename(index),\
114 self.playlist.song_size(index))
117 # next button and sets current song
119 self.amarok.player.next()
120 self.playlist.update(self.amarok.playlist.getActiveIndex() + 1,\
121 self.amarok.player.title(), \
122 self.amarok.player.artist(), \
123 self.amarok.player.path(), \
124 "." + self.amarok.player.type(), \
127 # prev button and sets current song
129 self.amarok.player.prev()
130 self.playlist.update(self.amarok.playlist.getActiveIndex() + 1,\
131 self.amarok.player.title(), \
132 self.amarok.player.artist(), \
133 self.amarok.player.path(), \
134 "." + self.amarok.player.type(), \
137 # play button and sets current song
139 self.amarok.player.play()
140 self.playlist.update(self.amarok.playlist.getActiveIndex() + 1,\
141 self.amarok.player.title(), \
142 self.amarok.player.artist(), \
143 self.amarok.player.path(), \
144 "." + self.amarok.player.type(), \
147 # play button with index song and sets current song
148 def play_track(self, index):
149 self.amarok.playlist.playByIndex(index-1)
150 self.playlist.update(index, \
151 self.amarok.player.title(), \
152 self.amarok.player.artist(), \
153 self.amarok.player.path(), \
154 "." + self.amarok.player.type(),\
158 def play_random(self):
159 index = random.randint(0, self.playlist.length() - 1)
160 self.amarok.playlist.playByIndex(index)
161 self.playlist.update(index+1, \
162 self.amarok.player.title(), \
163 self.amarok.player.artist(), \
164 self.amarok.player.path(), \
165 "." + self.amarok.player.type(),\
170 self.amarok.player.pause()
174 self.amarok.player.mute()
178 self.amarok.player.stop()
180 # get the current volume value
181 def get_volume(self):
182 return self.amarok.player.getVolume()
185 def volume_up(self, increase=1):
186 if (self.get_volume() + increase) <= 100:
187 up = self.get_volume() + increase
188 self.amarok.player.setVolume(up)
193 def volume_down(self, decrement=1):
194 if (self.get_volume() - decrement) >= 0:
195 down = self.get_volume() - decrement
196 self.amarok.player.setVolume(down)
201 def seek(self, value):
202 self.amarok.player.seek(value)