Author: duncan
Date: Mon Jan 7 16:45:02 2008
New Revision: 10266
Log:
Added header blocks, fixed the freevo plugins -i information
Run through reindent.py
Modified:
branches/rel-1-7/freevo/src/audio/plugins/mpd_playlist.py
branches/rel-1-7/freevo/src/audio/plugins/mpd_status.py
branches/rel-1-7/freevo/src/audio/plugins/mpdclient2.py
branches/rel-1/freevo/src/audio/plugins/mpd_playlist.py
branches/rel-1/freevo/src/audio/plugins/mpd_status.py
branches/rel-1/freevo/src/audio/plugins/mpdclient2.py
Modified: branches/rel-1-7/freevo/src/audio/plugins/mpd_playlist.py
==============================================================================
--- branches/rel-1-7/freevo/src/audio/plugins/mpd_playlist.py (original)
+++ branches/rel-1-7/freevo/src/audio/plugins/mpd_playlist.py Mon Jan 7
16:45:02 2008
@@ -1,62 +1,98 @@
-# This is a replacement for the previous mpd plugin
-# By Graham Billiau <[EMAIL PROTECTED]> (DrLizAu's code monkey)
-# This code is released under the GPL
-
-# There are two parts to this plugin, an addition to the audio item menu to
queue the item in mpd's playlist and a
-# status display in the audio menu
-
-# TODO:
+# -*- coding: iso-8859-1 -*-
+# -----------------------------------------------------------------------
+# This is the mpd playlist plugin. Using this you can add the currently
+# selected song to the mpd playlist
+# -----------------------------------------------------------------------
+# $Id$
+#
+# Notes:
+#
+# There are two parts to this plugin, an addition to the audio item menu to
queue
+# the item in mpd's playlist and a status display in the audio menu
+#
+# This only works if the music to be played is part of the filesystem avalible
to
+# mpd and also avalible to freevo so both on the same computer, or exported
using
+# samba or nfs
+#
+# Advantages of this over the previous mpd plugin:
+# The code is a lot cleaner and more robust.
+# Faster (talks to mpd directly, rather than calling other programs).
+# Allows you to modify the playlist within freevo.
+#
+# Todo:
+#
# add code to cope if the mpd server crashes
# add code to enqueue an entire directory & sub-directories
# add code to enqueue an existing playlist
# modify code to support localisation
# investigate having the mpd connection managed by another class
-
-# Advantages of this over the previous mpd plugin:
-# The code is a lot cleaner and more robust.
-# Faster (talks to mpd directly, rather than calling other programs).
-# Allows you to modify the playlist within freevo.
-
-# This only works if the music to be played is part of the filesystem avalible
to mpd and also avalible to freevo
-# so both on the same computer, or exported using samba or nfs
-
-# This code uses the following options in local_conf.py:
-# MPD_SERVER_HOST='localhost' # the host running the mpd server
-# MPD_SERVER_PORT='6600' # the port the server is listening on
-# MPD_SERVER_PASSWORD=None # the password to access the mpd server
-# MPD_MUSIC_BASE_PATH='/mnt/music/' # the local path to where the music
is stored, must have trailing slash
-# MPD_EXTERNAL_CLIENT='/usr/bin/pympd' # the location of the external
client you want to use, or None
-# MPD_EXTERNAL_CLIENT_ARGS='' # arguments to be passed to the external
client, or None, obsolete
-
-# This is the mpd playlist plugin.
-# using this you can add the currently selected song to the mpd playlist
+#
+# -----------------------------------------------------------------------
+# Freevo - A Home Theater PC framework
+# Copyright (C) 2002 Krister Lagerstrom, et al.
+# Please see the file freevo/Docs/CREDITS for a complete list of authors.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 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 MER-
+# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# -----------------------------------------------------------------------
import plugin
import config
-
import mpdclient2
-class PluginInterface (plugin.ItemPlugin):
- """This plugin adds a 'enqueue in MPD' option to audio files"""
+class PluginInterface(plugin.ItemPlugin):
+ """
+ This plugin adds a 'enqueue in MPD' option to audio files
+
+ To activate this plugin, just put the following line at the end of your
+ local_conf.py file:
+ | plugin.activate('audio.mpd_playlist')
+ """
+ __author__ = 'Graham Billiau (DrLizAu\'s code monkey)'
+ __author_email__ = '[EMAIL PROTECTED]'
+ __maintainer__ = __author__
+ __maintainer_email__ = __author_email__
+ __version__ = '$Revision$'
+ """open the connection to the mpd server and keep it alive
+ assume that the plugin is loaded once, then kept in memory"""
def __init__(self):
- """open the connection to the mpd server and keep it alive
- assume that the plugin is loaded once, then kept in memory"""
+ if not config.MPD_MUSIC_BASE_PATH:
+ self.reason = 'MPD_MUSIC_BASE_PATH not set in local_conf.py'
+ return
+
plugin.ItemPlugin.__init__(self)
self.conn = mpdclient2.Thread_MPD_Connection(config.MPD_SERVER_HOST,
config.MPD_SERVER_PORT, True,
config.MPD_SERVER_PASSWORD)
-
+
# ensure there is a trailing slash on config.MPD_MUSIC_BASE_PATH
if not config.MPD_MUSIC_BASE_PATH.endswith('/'):
config.MPD_MUSIC_BASE_PATH = config.MPD_MUSIC_BASE_PATH + '/'
def config(self):
- return [ ('MPD_SERVER_HOST', 'localhost', 'the host running the mpd
server'),
- ('MPD_SERVER_PORT', 6600, 'the port the server is listening
on'),
- ('MPD_SERVER_PASSWORD', None, 'the password to access the mpd
server'),
- ('MPD_MUSIC_BASE_PATH', '/mnt/music/', 'the local path to
where the music is stored') ]
+ """returns the config variables used by this plugin"""
+ return [
+ ('MPD_SERVER_HOST', 'localhost', 'the host running the mpd
server'),
+ ('MPD_SERVER_PORT', 6600, 'the port the server is listening on'),
+ ('MPD_SERVER_PASSWORD', None, 'the password to access the mpd
server'),
+ ('MPD_MUSIC_BASE_PATH', None, 'the local path to where the music
is stored'),
+ ('MPD_EXTERNAL_CLIENT', None,'the location of the external client
you want to use'),
+ #('MPD_EXTERNAL_CLIENT_ARGS', '','arguments to be passed to the
external client'),
+ ]
def shutdown(self):
@@ -93,4 +129,4 @@
#def enqueue_dir(self, arg=None, menuw=None):
- #def enqueue_playlist(self, arg=None, menuw=None):
\ No newline at end of file
+ #def enqueue_playlist(self, arg=None, menuw=None):
Modified: branches/rel-1-7/freevo/src/audio/plugins/mpd_status.py
==============================================================================
--- branches/rel-1-7/freevo/src/audio/plugins/mpd_status.py (original)
+++ branches/rel-1-7/freevo/src/audio/plugins/mpd_status.py Mon Jan 7
16:45:02 2008
@@ -1,16 +1,23 @@
-# This is a replacement for the previous mpd plugin
-# By Graham Billiau <[EMAIL PROTECTED]> (DrLizAu's code monkey)
-# This code is released under the GPL
-
-# There are two parts to this plugin, an addition to the audio item menu to
queue the item in mpd's playlist and a
-# status display in the audio menu
-
+# -*- coding: iso-8859-1 -*-
+# -----------------------------------------------------------------------
+# This is the status display. Using this you can see the currently playing
+# track, play, pause, stop, skip forward, skip back, toggle repeat, toggle
+# shuffle, clear playlist, open external playlist editor, change volume
+# -----------------------------------------------------------------------
+# $Id$
+#
+# Notes:
+#
+# There are two parts to this plugin, an addition to the audio item menu to
queue
+# the item in mpd's playlist and a status display in the audio menu
+#
# Advantages of this over the previous mpd plugin:
# The code is a lot cleaner and more robust.
# Faster (talks to mpd directly, rather than calling other programs).
# Allows you to modify the playlist within freevo.
-
-# TODO
+#
+# Todo:
+#
# enable localisation
# investigate having the mpd connection managed by another class
# pretty GUI
@@ -18,18 +25,26 @@
# add a playlist browser
# code to handle when the mpd server is down
# show the currently playing song in the status view
-
-# This code uses the following options in local_conf.py:
-# MPD_SERVER_HOST='localhost' # the host running the mpd server
-# MPD_SERVER_PORT='6600' # the port the server is listening on
-# MPD_SERVER_PASSWORD=None # the password to access the mpd server
-# MPD_MUSIC_BASE_PATH='/mnt/music' # the local path to where the music is
stored
-# MPD_EXTERNAL_CLIENT='/usr/bin/pympd' # the location of the external
client you want to use, or None
-# MPD_EXTERNAL_CLIENT_ARGS='' # arguments to be passed to the external
client, or None, obsolete
-
-# This is the status display.
-# using this you can see the currently playing track, play, pause, stop, skip
forward, skip back, toggle repeat, toggle
-# shuffle, clear playlist, open external playlist editor, change volume
+# -----------------------------------------------------------------------
+# Freevo - A Home Theater PC framework
+# Copyright (C) 2002 Krister Lagerstrom, et al.
+# Please see the file freevo/Docs/CREDITS for a complete list of authors.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 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 MER-
+# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# -----------------------------------------------------------------------
import plugin
import config
@@ -43,11 +58,28 @@
import mpdclient2
class PluginInterface(plugin.MainMenuPlugin):
- """This creates a new item in the audio menu
- Which allows you to view and modify the MPD settings"""
-
+ """
+ This creates a new item in the audio menu
+ Which allows you to view and modify the MPD settings
+
+ To activate this plugin, just put the following line at the end of your
+ local_conf.py file:
+
+ | plugin.activate('audio.mpd_status')
+ """
+ __author__ = 'Graham Billiau (DrLizAu\'s code monkey)'
+ __author_email__ = '[EMAIL PROTECTED]'
+ __maintainer__ = __author__
+ __maintainer_email__ = __author_email__
+ __version__ = '$Revision$'
+
+
def __init__(self):
- """ initilise the plugin"""
+ """Initilise the plugin"""
+ if not config.MPD_MUSIC_BASE_PATH:
+ self.reason = 'MPD_MUSIC_BASE_PATH not set in local_conf.py'
+ return
+
plugin.MainMenuPlugin.__init__(self)
self.show_item = menu.MenuItem('MPD status', action=self.show_menu)
self.show_item.type = 'audio'
@@ -55,7 +87,7 @@
# connect to the server
self.conn = mpdclient2.Thread_MPD_Connection(config.MPD_SERVER_HOST,
config.MPD_SERVER_PORT, True,
config.MPD_SERVER_PASSWORD)
-
+
# items to go in the mpd menu
self.item_play = menu.MenuItem('play', self.mpd_play)#, parent=self)
self.item_status = menu.MenuItem('status', self.mpd_status)#,
parent=self)
@@ -68,9 +100,20 @@
self.item_random = menu.MenuItem('toggle random',
self.mpd_toggle_random)#, parent=self)
self.item_repeat = menu.MenuItem('toggle repeat',
self.mpd_toggle_repeat)#, parent=self)
self.item_extern = menu.MenuItem('open external mpd client',
self.start_external)#, parent=self)
-
-
-
+
+
+ def config(self):
+ """returns the config variables used by this plugin"""
+ return [
+ ('MPD_SERVER_HOST', 'localhost', 'the host running the mpd
server'),
+ ('MPD_SERVER_PORT', 6600, 'the port the server is listening on'),
+ ('MPD_SERVER_PASSWORD', None, 'the password to access the mpd
server'),
+ ('MPD_MUSIC_BASE_PATH', None, 'the local path to where the music
is stored'),
+ ('MPD_EXTERNAL_CLIENT', None,'the location of the external client
you want to use'),
+ #('MPD_EXTERNAL_CLIENT_ARGS', '','arguments to be passed to the
external client'),
+ ]
+
+
def shutdown(self):
"""close the connection to the MPD server"""
try:
@@ -78,33 +121,24 @@
except EOFError:
# this always happens
pass
-
-
- def config(self):
- """returns the config variables used by this plugin"""
- return [ ('MPD_SERVER_HOST', 'localhost', 'the host running the mpd
server'),
- ('MPD_SERVER_PORT', 6600, 'the port the server is listening
on'),
- ('MPD_SERVER_PASSWORD', None, 'the password to access the mpd
server'),
- ('MPD_EXTERNAL_CLIENT', None,'the location of the external
client you want to use') ]
- #('MPD_EXTERNAL_CLIENT_ARGS', '','arguments to be passed to
the external client') ]
-
-
+
+
def items(self, parent):
"""returns the options to add to the main menu"""
return [ self.show_item ]
-
-
+
+
def actions(self):
"""extra options for this menu"""
return [ ]
-
-
+
+
def create_menu(self):
"""this creates the menu"""
-
+
menu_items = []
stat = self.conn.status()
-
+
# populate the menu
menu_items.append(self.item_status)
if (stat['state'] == 'play'):
@@ -123,58 +157,56 @@
menu_items.append(self.item_clear)
if not (config.MPD_EXTERNAL_CLIENT is None or
config.MPD_EXTERNAL_CLIENT == ''):
menu_items.append(self.item_extern)
-
+
return menu.Menu('MPD status', menu_items,
reload_func=self.create_menu)
-
-
+
+
def show_menu(self, arg=None, menuw=None):
"""this displays the menu"""
-
- # display the menu
mpd_menu = self.create_menu()
menuw.pushmenu(mpd_menu)
menuw.refresh()
-
-
+
+
def mpd_play(self, arg=None, menuw=None):
"""send the play command to the mpd server"""
self.conn.play()
- # force the menu to reload
- menuw.delete_menu()
- self.show_menu(arg, menuw)
-
-
+ # force the menu to reload
+ menuw.delete_menu()
+ self.show_menu(arg, menuw)
+
+
def mpd_next(self, arg=None, menuw=None):
"""send the play command to the mpd server"""
self.conn.next()
-
-
+
+
def mpd_previous(self, arg=None, menuw=None):
"""send the play command to the mpd server"""
self.conn.previous()
-
-
+
+
def mpd_stop(self, arg=None, menuw=None):
"""send the stop command to the mpd server"""
self.conn.stop()
- # force the menu to reload
- menuw.delete_menu()
- self.show_menu(arg, menuw)
-
-
+ # force the menu to reload
+ menuw.delete_menu()
+ self.show_menu(arg, menuw)
+
+
def mpd_pause(self, arg=None, menuw=None):
"""send the pause command to the mpd server"""
self.conn.pause(1)
- # force the menu to reload
- menuw.delete_menu()
- self.show_menu(arg, menuw)
-
-
+ # force the menu to reload
+ menuw.delete_menu()
+ self.show_menu(arg, menuw)
+
+
def mpd_shuffle(self, arg=None, menuw=None):
"""send the shuffle command to the mpd server"""
self.conn.shuffle()
-
-
+
+
def mpd_toggle_random(self, arg=None, menuw=None):
"""toggle random on/off to the mpd server"""
stat = self.conn.status()
@@ -182,8 +214,8 @@
self.conn.random(1)
else:
self.conn.random(0)
-
-
+
+
def mpd_toggle_repeat(self, arg=None, menuw=None):
"""toggle repeat on/off to the mpd server"""
stat = self.conn.status()
@@ -191,36 +223,36 @@
self.conn.repeat(1)
else:
self.conn.repeat(0)
-
-
+
+
def mpd_clear(self, arg=None, menuw=None):
"""send the clear command to the mpd server"""
self.conn.clear()
-
-
+
+
def start_external(self, arg=None, menuw=None):
"""start the external browser in the config file"""
if (config.MPD_EXTERNAL_CLIENT is None or config.MPD_EXTERNAL_CLIENT
== ''):
return
-
+
#if (config.MPD_EXTERNAL_CLIENT_ARGS is None or
config.MPD_EXTERNAL_CLIENT_ARGS == ''):
#args = None
#else:
#args = config.MPD_EXTERNAL_CLIENT_ARGS.split()
-
+
try:
#os,spawnv(os.P_NOWAIT, config.MPD_EXTERNAL_CLIENT, args)
- childapp.ChildApp(config.MPD_EXTERNAL_CLIENT)
+ childapp.ChildApp(config.MPD_EXTERNAL_CLIENT)
except:
text = "Error starting external client\n%s\n%s" %sys.exc_info()[:2]
pop = PopupBox(text)
pop.show()
-
-
+
+
def mpd_status(self, arg=None, menuw=None):
"""bring up a dialog showing mpd's current status"""
stat = self.conn.status()
-
+
text = "status: %s\n" %(stat['state'])
if (stat['state'] != 'stop'):
# how do i get the song name?
@@ -235,8 +267,6 @@
else:
text += "random: off\n"
text += "volume: %s" %(stat['volume'])
-
+
pop = PopupBox(text)
pop.show()
-
-
\ No newline at end of file
Modified: branches/rel-1-7/freevo/src/audio/plugins/mpdclient2.py
==============================================================================
--- branches/rel-1-7/freevo/src/audio/plugins/mpdclient2.py (original)
+++ branches/rel-1-7/freevo/src/audio/plugins/mpdclient2.py Mon Jan 7
16:45:02 2008
@@ -1,4 +1,8 @@
#!/usr/bin/env python
+# -*- coding: iso-8859-1 -*-
+# -----------------------------------------------------------------------
+# $Id$
+# -----------------------------------------------------------------------
# py-libmpdclient2 is written by Nick Welch <[EMAIL PROTECTED]>, 2005.
#
@@ -353,7 +357,7 @@
"""This is a wrapper around the mpdclient2 library to make it thread
safe"""
#conn
def __init__ (self, host, port, keepalive=False, pword = None):
- """create the connection and locks,
+ """create the connection and locks,
if keepalive is True the connection will not time out and must be
explcitly closed"""
self.conn = mpd_connection(host, port)
if (pword is not None):
Modified: branches/rel-1/freevo/src/audio/plugins/mpd_playlist.py
==============================================================================
--- branches/rel-1/freevo/src/audio/plugins/mpd_playlist.py (original)
+++ branches/rel-1/freevo/src/audio/plugins/mpd_playlist.py Mon Jan 7
16:45:02 2008
@@ -1,62 +1,98 @@
-# This is a replacement for the previous mpd plugin
-# By Graham Billiau <[EMAIL PROTECTED]> (DrLizAu's code monkey)
-# This code is released under the GPL
-
-# There are two parts to this plugin, an addition to the audio item menu to
queue the item in mpd's playlist and a
-# status display in the audio menu
-
-# TODO:
+# -*- coding: iso-8859-1 -*-
+# -----------------------------------------------------------------------
+# This is the mpd playlist plugin. Using this you can add the currently
+# selected song to the mpd playlist
+# -----------------------------------------------------------------------
+# $Id$
+#
+# Notes:
+#
+# There are two parts to this plugin, an addition to the audio item menu to
queue
+# the item in mpd's playlist and a status display in the audio menu
+#
+# This only works if the music to be played is part of the filesystem avalible
to
+# mpd and also avalible to freevo so both on the same computer, or exported
using
+# samba or nfs
+#
+# Advantages of this over the previous mpd plugin:
+# The code is a lot cleaner and more robust.
+# Faster (talks to mpd directly, rather than calling other programs).
+# Allows you to modify the playlist within freevo.
+#
+# Todo:
+#
# add code to cope if the mpd server crashes
# add code to enqueue an entire directory & sub-directories
# add code to enqueue an existing playlist
# modify code to support localisation
# investigate having the mpd connection managed by another class
-
-# Advantages of this over the previous mpd plugin:
-# The code is a lot cleaner and more robust.
-# Faster (talks to mpd directly, rather than calling other programs).
-# Allows you to modify the playlist within freevo.
-
-# This only works if the music to be played is part of the filesystem avalible
to mpd and also avalible to freevo
-# so both on the same computer, or exported using samba or nfs
-
-# This code uses the following options in local_conf.py:
-# MPD_SERVER_HOST='localhost' # the host running the mpd server
-# MPD_SERVER_PORT='6600' # the port the server is listening on
-# MPD_SERVER_PASSWORD=None # the password to access the mpd server
-# MPD_MUSIC_BASE_PATH='/mnt/music/' # the local path to where the music
is stored, must have trailing slash
-# MPD_EXTERNAL_CLIENT='/usr/bin/pympd' # the location of the external
client you want to use, or None
-# MPD_EXTERNAL_CLIENT_ARGS='' # arguments to be passed to the external
client, or None, obsolete
-
-# This is the mpd playlist plugin.
-# using this you can add the currently selected song to the mpd playlist
+#
+# -----------------------------------------------------------------------
+# Freevo - A Home Theater PC framework
+# Copyright (C) 2002 Krister Lagerstrom, et al.
+# Please see the file freevo/Docs/CREDITS for a complete list of authors.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 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 MER-
+# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# -----------------------------------------------------------------------
import plugin
import config
-
import mpdclient2
-class PluginInterface (plugin.ItemPlugin):
- """This plugin adds a 'enqueue in MPD' option to audio files"""
+class PluginInterface(plugin.ItemPlugin):
+ """
+ This plugin adds a 'enqueue in MPD' option to audio files
+
+ To activate this plugin, just put the following line at the end of your
+ local_conf.py file:
+ | plugin.activate('audio.mpd_playlist')
+ """
+ __author__ = 'Graham Billiau (DrLizAu\'s code monkey)'
+ __author_email__ = '[EMAIL PROTECTED]'
+ __maintainer__ = __author__
+ __maintainer_email__ = __author_email__
+ __version__ = '$Revision$'
+ """open the connection to the mpd server and keep it alive
+ assume that the plugin is loaded once, then kept in memory"""
def __init__(self):
- """open the connection to the mpd server and keep it alive
- assume that the plugin is loaded once, then kept in memory"""
+ if not config.MPD_MUSIC_BASE_PATH:
+ self.reason = 'MPD_MUSIC_BASE_PATH not set in local_conf.py'
+ return
+
plugin.ItemPlugin.__init__(self)
self.conn = mpdclient2.Thread_MPD_Connection(config.MPD_SERVER_HOST,
config.MPD_SERVER_PORT, True,
config.MPD_SERVER_PASSWORD)
-
+
# ensure there is a trailing slash on config.MPD_MUSIC_BASE_PATH
if not config.MPD_MUSIC_BASE_PATH.endswith('/'):
config.MPD_MUSIC_BASE_PATH = config.MPD_MUSIC_BASE_PATH + '/'
def config(self):
- return [ ('MPD_SERVER_HOST', 'localhost', 'the host running the mpd
server'),
- ('MPD_SERVER_PORT', 6600, 'the port the server is listening
on'),
- ('MPD_SERVER_PASSWORD', None, 'the password to access the mpd
server'),
- ('MPD_MUSIC_BASE_PATH', '/mnt/music/', 'the local path to
where the music is stored') ]
+ """returns the config variables used by this plugin"""
+ return [
+ ('MPD_SERVER_HOST', 'localhost', 'the host running the mpd
server'),
+ ('MPD_SERVER_PORT', 6600, 'the port the server is listening on'),
+ ('MPD_SERVER_PASSWORD', None, 'the password to access the mpd
server'),
+ ('MPD_MUSIC_BASE_PATH', None, 'the local path to where the music
is stored'),
+ ('MPD_EXTERNAL_CLIENT', None,'the location of the external client
you want to use'),
+ #('MPD_EXTERNAL_CLIENT_ARGS', '','arguments to be passed to the
external client'),
+ ]
def shutdown(self):
@@ -93,4 +129,4 @@
#def enqueue_dir(self, arg=None, menuw=None):
- #def enqueue_playlist(self, arg=None, menuw=None):
\ No newline at end of file
+ #def enqueue_playlist(self, arg=None, menuw=None):
Modified: branches/rel-1/freevo/src/audio/plugins/mpd_status.py
==============================================================================
--- branches/rel-1/freevo/src/audio/plugins/mpd_status.py (original)
+++ branches/rel-1/freevo/src/audio/plugins/mpd_status.py Mon Jan 7
16:45:02 2008
@@ -1,16 +1,23 @@
-# This is a replacement for the previous mpd plugin
-# By Graham Billiau <[EMAIL PROTECTED]> (DrLizAu's code monkey)
-# This code is released under the GPL
-
-# There are two parts to this plugin, an addition to the audio item menu to
queue the item in mpd's playlist and a
-# status display in the audio menu
-
+# -*- coding: iso-8859-1 -*-
+# -----------------------------------------------------------------------
+# This is the status display. Using this you can see the currently playing
+# track, play, pause, stop, skip forward, skip back, toggle repeat, toggle
+# shuffle, clear playlist, open external playlist editor, change volume
+# -----------------------------------------------------------------------
+# $Id$
+#
+# Notes:
+#
+# There are two parts to this plugin, an addition to the audio item menu to
queue
+# the item in mpd's playlist and a status display in the audio menu
+#
# Advantages of this over the previous mpd plugin:
# The code is a lot cleaner and more robust.
# Faster (talks to mpd directly, rather than calling other programs).
# Allows you to modify the playlist within freevo.
-
-# TODO
+#
+# Todo:
+#
# enable localisation
# investigate having the mpd connection managed by another class
# pretty GUI
@@ -18,18 +25,26 @@
# add a playlist browser
# code to handle when the mpd server is down
# show the currently playing song in the status view
-
-# This code uses the following options in local_conf.py:
-# MPD_SERVER_HOST='localhost' # the host running the mpd server
-# MPD_SERVER_PORT='6600' # the port the server is listening on
-# MPD_SERVER_PASSWORD=None # the password to access the mpd server
-# MPD_MUSIC_BASE_PATH='/mnt/music' # the local path to where the music is
stored
-# MPD_EXTERNAL_CLIENT='/usr/bin/pympd' # the location of the external
client you want to use, or None
-# MPD_EXTERNAL_CLIENT_ARGS='' # arguments to be passed to the external
client, or None, obsolete
-
-# This is the status display.
-# using this you can see the currently playing track, play, pause, stop, skip
forward, skip back, toggle repeat, toggle
-# shuffle, clear playlist, open external playlist editor, change volume
+# -----------------------------------------------------------------------
+# Freevo - A Home Theater PC framework
+# Copyright (C) 2002 Krister Lagerstrom, et al.
+# Please see the file freevo/Docs/CREDITS for a complete list of authors.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 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 MER-
+# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# -----------------------------------------------------------------------
import plugin
import config
@@ -43,11 +58,28 @@
import mpdclient2
class PluginInterface(plugin.MainMenuPlugin):
- """This creates a new item in the audio menu
- Which allows you to view and modify the MPD settings"""
-
+ """
+ This creates a new item in the audio menu
+ Which allows you to view and modify the MPD settings
+
+ To activate this plugin, just put the following line at the end of your
+ local_conf.py file:
+
+ | plugin.activate('audio.mpd_status')
+ """
+ __author__ = 'Graham Billiau (DrLizAu\'s code monkey)'
+ __author_email__ = '[EMAIL PROTECTED]'
+ __maintainer__ = __author__
+ __maintainer_email__ = __author_email__
+ __version__ = '$Revision$'
+
+
def __init__(self):
- """ initilise the plugin"""
+ """Initilise the plugin"""
+ if not config.MPD_MUSIC_BASE_PATH:
+ self.reason = 'MPD_MUSIC_BASE_PATH not set in local_conf.py'
+ return
+
plugin.MainMenuPlugin.__init__(self)
self.show_item = menu.MenuItem('MPD status', action=self.show_menu)
self.show_item.type = 'audio'
@@ -55,7 +87,7 @@
# connect to the server
self.conn = mpdclient2.Thread_MPD_Connection(config.MPD_SERVER_HOST,
config.MPD_SERVER_PORT, True,
config.MPD_SERVER_PASSWORD)
-
+
# items to go in the mpd menu
self.item_play = menu.MenuItem('play', self.mpd_play)#, parent=self)
self.item_status = menu.MenuItem('status', self.mpd_status)#,
parent=self)
@@ -68,9 +100,20 @@
self.item_random = menu.MenuItem('toggle random',
self.mpd_toggle_random)#, parent=self)
self.item_repeat = menu.MenuItem('toggle repeat',
self.mpd_toggle_repeat)#, parent=self)
self.item_extern = menu.MenuItem('open external mpd client',
self.start_external)#, parent=self)
-
-
-
+
+
+ def config(self):
+ """returns the config variables used by this plugin"""
+ return [
+ ('MPD_SERVER_HOST', 'localhost', 'the host running the mpd
server'),
+ ('MPD_SERVER_PORT', 6600, 'the port the server is listening on'),
+ ('MPD_SERVER_PASSWORD', None, 'the password to access the mpd
server'),
+ ('MPD_MUSIC_BASE_PATH', None, 'the local path to where the music
is stored'),
+ ('MPD_EXTERNAL_CLIENT', None,'the location of the external client
you want to use'),
+ #('MPD_EXTERNAL_CLIENT_ARGS', '','arguments to be passed to the
external client'),
+ ]
+
+
def shutdown(self):
"""close the connection to the MPD server"""
try:
@@ -78,33 +121,24 @@
except EOFError:
# this always happens
pass
-
-
- def config(self):
- """returns the config variables used by this plugin"""
- return [ ('MPD_SERVER_HOST', 'localhost', 'the host running the mpd
server'),
- ('MPD_SERVER_PORT', 6600, 'the port the server is listening
on'),
- ('MPD_SERVER_PASSWORD', None, 'the password to access the mpd
server'),
- ('MPD_EXTERNAL_CLIENT', None,'the location of the external
client you want to use') ]
- #('MPD_EXTERNAL_CLIENT_ARGS', '','arguments to be passed to
the external client') ]
-
-
+
+
def items(self, parent):
"""returns the options to add to the main menu"""
return [ self.show_item ]
-
-
+
+
def actions(self):
"""extra options for this menu"""
return [ ]
-
-
+
+
def create_menu(self):
"""this creates the menu"""
-
+
menu_items = []
stat = self.conn.status()
-
+
# populate the menu
menu_items.append(self.item_status)
if (stat['state'] == 'play'):
@@ -123,58 +157,56 @@
menu_items.append(self.item_clear)
if not (config.MPD_EXTERNAL_CLIENT is None or
config.MPD_EXTERNAL_CLIENT == ''):
menu_items.append(self.item_extern)
-
+
return menu.Menu('MPD status', menu_items,
reload_func=self.create_menu)
-
-
+
+
def show_menu(self, arg=None, menuw=None):
"""this displays the menu"""
-
- # display the menu
mpd_menu = self.create_menu()
menuw.pushmenu(mpd_menu)
menuw.refresh()
-
-
+
+
def mpd_play(self, arg=None, menuw=None):
"""send the play command to the mpd server"""
self.conn.play()
- # force the menu to reload
- menuw.delete_menu()
- self.show_menu(arg, menuw)
-
-
+ # force the menu to reload
+ menuw.delete_menu()
+ self.show_menu(arg, menuw)
+
+
def mpd_next(self, arg=None, menuw=None):
"""send the play command to the mpd server"""
self.conn.next()
-
-
+
+
def mpd_previous(self, arg=None, menuw=None):
"""send the play command to the mpd server"""
self.conn.previous()
-
-
+
+
def mpd_stop(self, arg=None, menuw=None):
"""send the stop command to the mpd server"""
self.conn.stop()
- # force the menu to reload
- menuw.delete_menu()
- self.show_menu(arg, menuw)
-
-
+ # force the menu to reload
+ menuw.delete_menu()
+ self.show_menu(arg, menuw)
+
+
def mpd_pause(self, arg=None, menuw=None):
"""send the pause command to the mpd server"""
self.conn.pause(1)
- # force the menu to reload
- menuw.delete_menu()
- self.show_menu(arg, menuw)
-
-
+ # force the menu to reload
+ menuw.delete_menu()
+ self.show_menu(arg, menuw)
+
+
def mpd_shuffle(self, arg=None, menuw=None):
"""send the shuffle command to the mpd server"""
self.conn.shuffle()
-
-
+
+
def mpd_toggle_random(self, arg=None, menuw=None):
"""toggle random on/off to the mpd server"""
stat = self.conn.status()
@@ -182,8 +214,8 @@
self.conn.random(1)
else:
self.conn.random(0)
-
-
+
+
def mpd_toggle_repeat(self, arg=None, menuw=None):
"""toggle repeat on/off to the mpd server"""
stat = self.conn.status()
@@ -191,36 +223,36 @@
self.conn.repeat(1)
else:
self.conn.repeat(0)
-
-
+
+
def mpd_clear(self, arg=None, menuw=None):
"""send the clear command to the mpd server"""
self.conn.clear()
-
-
+
+
def start_external(self, arg=None, menuw=None):
"""start the external browser in the config file"""
if (config.MPD_EXTERNAL_CLIENT is None or config.MPD_EXTERNAL_CLIENT
== ''):
return
-
+
#if (config.MPD_EXTERNAL_CLIENT_ARGS is None or
config.MPD_EXTERNAL_CLIENT_ARGS == ''):
#args = None
#else:
#args = config.MPD_EXTERNAL_CLIENT_ARGS.split()
-
+
try:
#os,spawnv(os.P_NOWAIT, config.MPD_EXTERNAL_CLIENT, args)
- childapp.ChildApp(config.MPD_EXTERNAL_CLIENT)
+ childapp.ChildApp(config.MPD_EXTERNAL_CLIENT)
except:
text = "Error starting external client\n%s\n%s" %sys.exc_info()[:2]
pop = PopupBox(text)
pop.show()
-
-
+
+
def mpd_status(self, arg=None, menuw=None):
"""bring up a dialog showing mpd's current status"""
stat = self.conn.status()
-
+
text = "status: %s\n" %(stat['state'])
if (stat['state'] != 'stop'):
# how do i get the song name?
@@ -235,8 +267,6 @@
else:
text += "random: off\n"
text += "volume: %s" %(stat['volume'])
-
+
pop = PopupBox(text)
pop.show()
-
-
\ No newline at end of file
Modified: branches/rel-1/freevo/src/audio/plugins/mpdclient2.py
==============================================================================
--- branches/rel-1/freevo/src/audio/plugins/mpdclient2.py (original)
+++ branches/rel-1/freevo/src/audio/plugins/mpdclient2.py Mon Jan 7
16:45:02 2008
@@ -1,4 +1,8 @@
#!/usr/bin/env python
+# -*- coding: iso-8859-1 -*-
+# -----------------------------------------------------------------------
+# $Id$
+# -----------------------------------------------------------------------
# py-libmpdclient2 is written by Nick Welch <[EMAIL PROTECTED]>, 2005.
#
@@ -353,7 +357,7 @@
"""This is a wrapper around the mpdclient2 library to make it thread
safe"""
#conn
def __init__ (self, host, port, keepalive=False, pword = None):
- """create the connection and locks,
+ """create the connection and locks,
if keepalive is True the connection will not time out and must be
explcitly closed"""
self.conn = mpd_connection(host, port)
if (pword is not None):
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog