X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=pcremote-server-desktop%2Fplayers%2F.svn%2Ftext-base%2Famarok.py.svn-base;fp=pcremote-server-desktop%2Fplayers%2F.svn%2Ftext-base%2Famarok.py.svn-base;h=5e235b3c8243ec5e1a1595d1520784721d088049;hb=8eeea3225c010dea378cdc71c4e91294e04a6e9c;hp=0000000000000000000000000000000000000000;hpb=e8447209e336f2a6845027f50b84cc914fa2c796;p=remotepc diff --git a/pcremote-server-desktop/players/.svn/text-base/amarok.py.svn-base b/pcremote-server-desktop/players/.svn/text-base/amarok.py.svn-base new file mode 100755 index 0000000..5e235b3 --- /dev/null +++ b/pcremote-server-desktop/players/.svn/text-base/amarok.py.svn-base @@ -0,0 +1,202 @@ +# -*- coding: utf-8 -*- + +# **************************************************************************** +# Copyright (c) 2008 INdT/Fucapi. +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program. If not, see . +# +# ============================================================================ +# Project Name : PC Remote +# Author : Jonatas Isvi +# Email : jonatas.nona@gmail.com +# Reviewer : +# Email : +# Version : 1.0 +# Packge : players +# Description : Amarok Player +# ============================================================================ + +import os +import commands +import random +from playlist import Playlist +import pydcop + +# command line +def shell(command): + return commands.getoutput(command) + +# starts the amarok player application +def start(): + os.popen('amarok') + +# close the amarok player application +def shutdown(): + shell('dcop amarok player stop') + pid = shell('pidof amarokapp') + shell('kill -9 %s' % pid) + +# verifies if the amarok is running +def isRunning(): + pid = shell('pidof amarokapp') + if pid > 0: + return True + else: + return False + +class AmarokPlayer(): + + """ Amarok + Define all states and functions of amarok player. + This class will build to support PCRemote Player, + receiving messages from any devices with a bluetooth + connection. + """ + + # some importants variables + def __init__(self): + self.amarok = pydcop.anyAppCalled("amarok") + self.playlist = Playlist(self.amarok.playlist.saveCurrentPlaylist()) + self.isPlaying() + + # refresh playlist, accessing the Playlist class instance + def refresh_playlist(self): + self.playlist = Playlist(self.amarok.playlist.saveCurrentPlaylist()) + self.isPlaying() + + # get all songs of playlist + def song_list(self): + self.playlist.show() + + # show current song, acessing the Playlist class instance + def current_song(self): + self.isPlaying() + + # verifies if this amarok app is running + def isRunning(self): + aux = pydcop.anyAppCalled("amarok") + if aux: + return aux + else: + return None + + # verifies if this amarok app is playing and update the + # Playlist with current song + def isPlaying(self): + if not self.amarok.player.isPlaying() == 'true': + self.playlist.update(self.amarok.playlist.getActiveIndex() + 1,\ + self.amarok.player.title(), \ + self.amarok.player.artist(), \ + self.amarok.player.path(), \ + "." + self.amarok.player.type(), \ + ) + return True + else: + return False + + # get the players name + def getName(self): + return "Amarok" + + # send audio files to the N810 device + def audio_file_properties(self, index=None): + audiofile = (self.playlist.song_filename(index),\ + self.playlist.song_size(index)) + return audiofile + + # next button and sets current song + def next(self): + self.amarok.player.next() + self.playlist.update(self.amarok.playlist.getActiveIndex() + 1,\ + self.amarok.player.title(), \ + self.amarok.player.artist(), \ + self.amarok.player.path(), \ + "." + self.amarok.player.type(), \ + ) + + # prev button and sets current song + def prev(self): + self.amarok.player.prev() + self.playlist.update(self.amarok.playlist.getActiveIndex() + 1,\ + self.amarok.player.title(), \ + self.amarok.player.artist(), \ + self.amarok.player.path(), \ + "." + self.amarok.player.type(), \ + ) + + # play button and sets current song + def play(self): + self.amarok.player.play() + self.playlist.update(self.amarok.playlist.getActiveIndex() + 1,\ + self.amarok.player.title(), \ + self.amarok.player.artist(), \ + self.amarok.player.path(), \ + "." + self.amarok.player.type(), \ + ) + + # play button with index song and sets current song + def play_track(self, index): + self.amarok.playlist.playByIndex(index-1) + self.playlist.update(index, \ + self.amarok.player.title(), \ + self.amarok.player.artist(), \ + self.amarok.player.path(), \ + "." + self.amarok.player.type(),\ + ) + + # random play songs + def play_random(self): + index = random.randint(0, self.playlist.length() - 1) + self.amarok.playlist.playByIndex(index) + self.playlist.update(index+1, \ + self.amarok.player.title(), \ + self.amarok.player.artist(), \ + self.amarok.player.path(), \ + "." + self.amarok.player.type(),\ + ) + + # pause button + def pause(self): + self.amarok.player.pause() + + # mute button + def mute(self): + self.amarok.player.mute() + + # stop button + def stop(self): + self.amarok.player.stop() + + # get the current volume value + def get_volume(self): + return self.amarok.player.getVolume() + + # set up volume + def volume_up(self, increase=1): + if (self.get_volume() + increase) <= 100: + up = self.get_volume() + increase + self.amarok.player.setVolume(up) + else: + print "erro!" + + # set down volume + def volume_down(self, decrement=1): + if (self.get_volume() - decrement) >= 0: + down = self.get_volume() - decrement + self.amarok.player.setVolume(down) + else: + print "erro!" + + # set seek value + def seek(self, value): + self.amarok.player.seek(value)