]> kaliko git repositories - mpd-sima.git/blob - sima/plugins/core/mpdoptions.py
Enhanced queuing behavior in random mode (Closes #16)
[mpd-sima.git] / sima / plugins / core / mpdoptions.py
1 # -*- coding: utf-8 -*-
2 # Copyright (c) 2013, 2014 Jack Kaliko <kaliko@azylum.org>
3 #
4 #  This file is part of sima
5 #
6 #  sima is free software: you can redistribute it and/or modify
7 #  it under the terms of the GNU General Public License as published by
8 #  the Free Software Foundation, either version 3 of the License, or
9 #  (at your option) any later version.
10 #
11 #  sima is distributed in the hope that it will be useful,
12 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 #  GNU General Public License for more details.
15 #
16 #  You should have received a copy of the GNU General Public License
17 #  along with sima.  If not, see <http://www.gnu.org/licenses/>.
18 #
19 #
20 """
21     Deal with MPD options ‑ idle and repeat mode
22 """
23
24 # standard library import
25
26 # third parties components
27
28 # local import
29 from ...lib.plugin import Plugin
30
31
32 class MpdOptions(Plugin):
33     """
34     Deal with MPD options - idle and repeat mode
35     """
36
37     def __init__(self, daemon):
38         Plugin.__init__(self, daemon)
39         self.daemon = daemon
40
41     def callback_player(self):
42         """
43         Called on player changes
44         """
45         player = self.daemon.player
46         if player.playmode.get('single'):
47             self.log.info('MPD "single" mode activated.')
48             self.daemon.enabled = False
49         elif player.playmode.get('repeat'):
50             self.log.info('MPD "repeat" mode activated.')
51             self.daemon.enabled = False
52         else:
53             if self.daemon.enabled is False:
54                 self.log.debug('enabling queuing (leaving single|repeat mode)')
55                 self.daemon.enabled = True
56
57     def shutdown(self):
58         pass
59
60
61 # VIM MODLINE
62 # vim: ai ts=4 sw=4 sts=4 expandtab