Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bushvin committed Oct 31, 2023
1 parent 2339104 commit d2195dd
Showing 1 changed file with 1 addition and 39 deletions.
40 changes: 1 addition & 39 deletions custom_components/mopidy/speaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,17 +337,6 @@ def uri(self):
"""Return the URI of the current track"""
return self._attr_track_uri

# class MopidyQueue:
# """Mopidy doesn't provide information about the playlist a song which is being played"""
# api: MopidyAPI | None = None

# _queue: list | None = None

# def __init__(self):
# self._queue = []



class MopidySpeaker:

hass: HomeAssistant | None = None
Expand Down Expand Up @@ -408,7 +397,6 @@ def __init__(self,
self.media = MopidyMedia()
self.media.set_local_url_base(f"http://{hostname}:{port}")
self.library = MopidyLibrary()
# self.queue = MopidyQueue()

self.api = MopidyAPI(
host=self.hostname,
Expand All @@ -418,7 +406,7 @@ def __init__(self,
)
self.media.api = self.api
self.library.api = self.api
# self.queue.api = self.api


def clear(self):
"""Reset all Values"""
Expand Down Expand Up @@ -450,10 +438,6 @@ def update(self):
_LOGGER.debug(str(error))
return

# if not self._attr_is_available:
# _LOGGER.debug("Waiting for network connectivity to be established")
# return

self._attr_software_version = self.api.rpc_call("core.get_version")
self._attr_supported_uri_schemes = self.api.rpc_call("core.get_uri_schemes")
self._attr_consume_mode = self.api.tracklist.get_consume()
Expand Down Expand Up @@ -486,29 +470,11 @@ def update(self):
self._attr_repeat = RepeatMode.OFF

self.media.update()
# self.queue.update()

def clear_queue(self):
"""Clear the playing queue"""
self.api.tracklist.clear()

def connect(self):
self.api = MopidyAPI(
host=self.hostname,
port=self.port,
use_websocket=False,
logger=logging.getLogger(__name__ + ".client"),
)
_LOGGER.info(
"Connection to Mopidy server %s on port %d established",
self.hostname,
self.port,
)

self._attr_is_available = True
self.media.api = self.api
self.library.api = self.api

def media_next_track(self):
"""Play next track"""
self.api.playback.next()
Expand Down Expand Up @@ -560,11 +526,7 @@ def play_media(self, media_type, media_id, **kwargs):
self.queue_tracks(media_uris, at_position=index+1)

elif enqueue == MediaPlayerEnqueue.PLAY:
# tracks = self.tracklist_uris
index = self.queue_position
# new_media_uris = tracks[:index] + media_uris + tracks[index+1:]
self.clear_queue()
# self.queue_tracks(new_media_uris)
self.queue_tracks(media_uris, at_position=index)
self.media_play(index)

Expand Down

0 comments on commit d2195dd

Please sign in to comment.