Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Commit

Permalink
resync repo
Browse files Browse the repository at this point in the history
  • Loading branch information
nagyrobi committed Apr 22, 2022
1 parent bccbbab commit 624c146
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion custom_components/linkplay/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"domain": "linkplay",
"name": "Linkplay",
"version":"3.1.3",
"version":"3.1.4",
"documentation": "https://github.com/nagyrobi/home-assistant-custom-components-linkplay",
"issue_tracker": "https://github.com/nagyrobi/home-assistant-custom-components-linkplay/issues",
"after_dependencies": ["http", "tts", "media_source"],
Expand Down
30 changes: 16 additions & 14 deletions custom_components/linkplay/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
ICON_MULTIROOM = 'mdi:speaker-multiple'
ICON_BLUETOOTH = 'mdi:speaker-bluetooth'
ICON_PUSHSTREAM = 'mdi:cast-audio'
ICON_TTS = 'mdi:text-to-speech'

ATTR_SLAVE = 'slave'
ATTR_LINKPLAY_GROUP = 'linkplay_group'
Expand Down Expand Up @@ -515,7 +516,7 @@ async def async_update(self):
self._playhead_position = 0
self._duration = 0
self._position_updated_at = utcnow()
self._idletime_updated_at = utcnow()
self._idletime_updated_at = self._position_updated_at
# await self.async_restore_previous_source()
await self.async_select_source(self._multiroom_prevsrc)
self._multiroom_prevsrc = None
Expand Down Expand Up @@ -869,6 +870,10 @@ def name(self):
@property
def icon(self):
"""Return the icon of the device."""

if self._playing_tts:
return ICON_TTS

if self._state in [STATE_PAUSED, STATE_UNAVAILABLE, STATE_IDLE, STATE_UNKNOWN]:
return ICON_DEFAULT

Expand Down Expand Up @@ -1007,10 +1012,7 @@ def repeat(self):
@property
def media_title(self):
"""Return title of the current track."""
if self._playing_tts:
return "TTS"
else:
return self._media_title
return self._media_title

@property
def media_artist(self):
Expand Down Expand Up @@ -1194,7 +1196,7 @@ async def async_media_play(self):
self._unav_throttle = False
#self._playing_tts = False
self._position_updated_at = utcnow()
self._idletime_updated_at = utcnow()
self._idletime_updated_at = self._position_updated_at
if self._slave_list is not None:
for slave in self._slave_list:
await slave.async_set_state(self._state)
Expand All @@ -1216,7 +1218,7 @@ async def async_media_pause(self):
value = await self.call_linkplay_httpapi("setPlayerCmd:pause", None)
if value == "OK":
self._position_updated_at = utcnow()
self._idletime_updated_at = utcnow()
self._idletime_updated_at = self._position_updated_at
if self._playing_spotify:
self._spotify_paused_at = utcnow()
self._state = STATE_PAUSED
Expand Down Expand Up @@ -1266,7 +1268,7 @@ async def async_media_stop(self):
self._trackc = None
self._media_image_url = None
self._position_updated_at = utcnow()
self._idletime_updated_at = utcnow()
self._idletime_updated_at = self._position_updated_at
self._spotify_paused_at = None
#await self.async_schedule_update_ha_state(True)
if self._slave_list is not None:
Expand All @@ -1284,7 +1286,7 @@ async def async_media_seek(self, position):
if self._duration > 0 and position >= 0 and position <= self._duration:
value = await self.call_linkplay_httpapi("setPlayerCmd:seek:{0}".format(str(position)), None)
self._position_updated_at = utcnow()
self._idletime_updated_at = utcnow()
self._idletime_updated_at = self._position_updated_at
self._wait_for_mcu = 0.2
if value != "OK":
_LOGGER.warning("Failed to seek. Device: %s, Got response: %s", self.entity_id, value)
Expand Down Expand Up @@ -1364,7 +1366,7 @@ async def async_play_media(self, media_type, media_id, **kwargs):
else:
media_id_final = await self.async_detect_stream_url_redirection(media_id)

if self._fwvercheck(self._fw_ver) >= self._fwvercheck(FW_SLOW_STREAMS):
if self._fwvercheck(self._fw_ver) >= self._fwvercheck(FW_SLOW_STREAMS) and self._state == STATE_PLAYING:
await self.call_linkplay_httpapi("setPlayerCmd:pause", None)

if self._playing_spotify: # disconnect from Spotify before playing new http source
Expand Down Expand Up @@ -1397,7 +1399,7 @@ async def async_play_media(self, media_type, media_id, **kwargs):
self._duration = 0
self._trackc = None
self._position_updated_at = utcnow()
self._idletime_updated_at = utcnow()
self._idletime_updated_at = self._position_updated_at
self._media_image_url = None
self._ice_skip_throt = True
self._unav_throttle = False
Expand Down Expand Up @@ -1440,7 +1442,7 @@ async def async_select_source(self, source):
if temp_source.startswith('http'):
temp_source_final = await self.async_detect_stream_url_redirection(temp_source)

if self._fwvercheck(self._fw_ver) >= self._fwvercheck(FW_SLOW_STREAMS):
if self._fwvercheck(self._fw_ver) >= self._fwvercheck(FW_SLOW_STREAMS) and self._state == STATE_PLAYING:
await self.call_linkplay_httpapi("setPlayerCmd:pause", None) #recent firmwares don't stop the previous stream while loading the new one, can take several seconds

value = await self.call_linkplay_httpapi("setPlayerCmd:play:{0}".format(temp_source_final), None)
Expand All @@ -1458,7 +1460,7 @@ async def async_select_source(self, source):
self._duration = 0
self._trackc = None
self._position_updated_at = utcnow()
self._idletime_updated_at = utcnow()
self._idletime_updated_at = self._position_updated_at
self._media_title = None
self._media_artist = None
self._media_album = None
Expand All @@ -1485,7 +1487,7 @@ async def async_select_source(self, source):
self._duration = 0
self._trackc = None
self._position_updated_at = utcnow()
self._idletime_updated_at = utcnow()
self._idletime_updated_at = self._position_updated_at
if self._slave_list is not None:
for slave in self._slave_list:
await slave.async_set_source(source)
Expand Down

0 comments on commit 624c146

Please sign in to comment.