Skip to content

Commit

Permalink
Added inheritance class for players
Browse files Browse the repository at this point in the history
  • Loading branch information
Groovylein committed Nov 18, 2023
1 parent b8fd417 commit 9006d6f
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 2 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
36 changes: 36 additions & 0 deletions src/jukebox/components/player/backends/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
class BackendPlayer:
"""
Class to inherit, so that you can build a proper new Player
"""
def __init__(self):
raise NotImplementedError

def next(self):
raise NotImplementedError

def prev(self):
raise NotImplementedError

def play(self, idx=None):
raise NotImplementedError

def toggle(self):
raise NotImplementedError

def pause(self):
raise NotImplementedError

def stop(self):
raise NotImplementedError

def get_queue(self):
raise NotImplementedError

def play_uri(self, uri):
raise NotImplementedError

def repeatmode(self):
raise NotImplementedError

def seek(self):
raise NotImplementedError
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import jukebox.cfghandler

from mpd.asyncio import MPDClient
from components.player.backends import BackendPlayer

logger = logging.getLogger('jb.mpd')
cfg = jukebox.cfghandler.get_handler('jukebox')
Expand All @@ -19,7 +20,7 @@ def sanitize(path: str):
return os.path.normpath(path).lstrip('./')


class MPDBackend:
class MPDBackend(BackendPlayer):

def __init__(self, event_loop):
self.client = MPDClient()
Expand Down
12 changes: 12 additions & 0 deletions src/jukebox/components/player/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ def prev(self):
def play(self):
self._active.play()

@plugin.tag
def play_single(self, uri):
self.play_uri(uri)

@plugin.tag
def toggle(self):
self._active.toggle()
Expand All @@ -126,6 +130,14 @@ def stop(self):
def get_queue(self):
self._active.get_queue()

@plugin.tag
def repeatmode(self):
self._active.repeatmode()

@plugin.tag
def seek(self):
self._active.seek()

def _save_state(self):
# Get the backend to save the state of the current playlist to the URI's config file
self._active.save_state()
Expand Down
7 changes: 7 additions & 0 deletions src/webapp/src/commands/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,32 @@ const commands = {
plugin: 'ctrl',
method: 'get_by_filename_as_base64',
},
// ToDo: Implement
directoryTreeOfAudiofolder: {
_package: 'player',
plugin: 'ctrl',
method: 'list_all_dirs',
},
// ToDo: Implement new player
albumList: {
_package: 'player',
plugin: 'ctrl',
method: 'list_albums',
},
// ToDo: Implement
songList: {
_package: 'player',
plugin: 'ctrl',
method: 'list_song_by_artist_and_album',
},
// ToDo: Implement
getSongByUrl: {
_package: 'player',
plugin: 'ctrl',
method: 'get_song_by_url',
argKeys: ['song_url']
},
// ToDo: Implement
folderList: {
_package: 'player',
plugin: 'ctrl',
Expand Down Expand Up @@ -60,12 +65,14 @@ const commands = {
method: 'play_single',
argKeys: ['song_url']
},
// ToDo: verify if this is really needed?
play_folder: {
_package: 'player',
plugin: 'ctrl',
method: 'play_folder',
argKeys: ['folder']
},
// ToDo: Implement
play_album: {
_package: 'player',
plugin: 'ctrl',
Expand Down
2 changes: 1 addition & 1 deletion src/webapp/src/components/Library/lists/albums/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const Albums = ({ musicFilter }) => {
<>
{isLoading
? <CircularProgress />
: <AlbumListmpd
: <AlbumList
albums={albums.filter(search)}
musicFilter={musicFilter}
/>}
Expand Down

0 comments on commit 9006d6f

Please sign in to comment.