-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from confirm/add-next-previous-actions
FEATURE: Add next & previous track actions
- Loading branch information
Showing
21 changed files
with
417 additions
and
371 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
''' | ||
Python module for Mopidy Pummeluff playback actions. | ||
''' | ||
|
||
__all__ = ( | ||
'PlayPause', | ||
'Stop', | ||
'PreviousTrack', | ||
'NextTrack', | ||
) | ||
|
||
from logging import getLogger | ||
|
||
from .base import Action | ||
|
||
LOGGER = getLogger(__name__) | ||
|
||
|
||
class PlayPause(Action): | ||
''' | ||
Pauses or resumes the playback, based on the current state. | ||
''' | ||
|
||
@classmethod | ||
def execute(cls, core): | ||
''' | ||
Pause or resume the playback. | ||
:param mopidy.core.Core core: The mopidy core instance | ||
''' | ||
playback = core.playback | ||
|
||
if playback.get_state().get() == 'playing': | ||
LOGGER.info('Pausing the playback') | ||
playback.pause() | ||
else: | ||
LOGGER.info('Resuming the playback') | ||
playback.resume() | ||
|
||
|
||
class Stop(Action): | ||
''' | ||
Stops the playback. | ||
''' | ||
|
||
@classmethod | ||
def execute(cls, core): | ||
''' | ||
Stop playback. | ||
:param mopidy.core.Core core: The mopidy core instance | ||
''' | ||
LOGGER.info('Stopping playback') | ||
core.playback.stop() | ||
|
||
|
||
class PreviousTrack(Action): | ||
''' | ||
Changes to the previous track. | ||
''' | ||
|
||
@classmethod | ||
def execute(cls, core): | ||
''' | ||
Change to previous track. | ||
:param mopidy.core.Core core: The mopidy core instance | ||
''' | ||
LOGGER.info('Changing to previous track') | ||
core.playback.previous() | ||
|
||
|
||
class NextTrack(Action): | ||
''' | ||
Changes to the next track. | ||
''' | ||
|
||
@classmethod | ||
def execute(cls, core): | ||
''' | ||
Change to next track. | ||
:param mopidy.core.Core core: The mopidy core instance | ||
''' | ||
LOGGER.info('Changing to next track') | ||
core.playback.next() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
''' | ||
Python module for Mopidy Pummeluff shutdown tag. | ||
''' | ||
|
||
__all__ = ( | ||
'Shutdown', | ||
) | ||
|
||
from logging import getLogger | ||
from os import system | ||
|
||
from .base import Action | ||
|
||
LOGGER = getLogger(__name__) | ||
|
||
|
||
class Shutdown(Action): | ||
''' | ||
Shutting down the system. | ||
''' | ||
|
||
@classmethod | ||
def execute(cls, core): | ||
''' | ||
Shutdown. | ||
:param mopidy.core.Core core: The mopidy core instance | ||
''' | ||
LOGGER.info('Shutting down') | ||
system('sudo /sbin/shutdown -h now') |
Oops, something went wrong.