Skip to content

Commit

Permalink
Implement player state (idle/playing)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jalle19 committed Sep 10, 2024
1 parent cb7634d commit a70cc25
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion custom_components/vinx/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ def name(self):


class VinxEncoder(AbstractVinxMediaPlayerEntity):
pass
async def async_update(self):
async with self._lw3.connection():
# Query signal status
signal_present = await self._lw3.get_property("/MEDIA/VIDEO/I1.SignalPresent")
self._state = MediaPlayerState.PLAYING if str(signal_present) == "1" else MediaPlayerState.IDLE


class VinxDecoder(AbstractVinxMediaPlayerEntity):
Expand All @@ -88,9 +92,14 @@ async def async_update(self):
_LOGGER.info(f"{self.name} source list populated with {len(self._source_list)} sources")

async with self._lw3.connection():
# Query current source
video_channel_id = await self._lw3.get_property("/SYS/MB/PHY.VideoChannelId")
self._source = str(self._source_bidict.get(str(video_channel_id)))

# Query signal status
signal_present = await self._lw3.get_property("/MEDIA/VIDEO/I1.SignalPresent")
self._state = MediaPlayerState.PLAYING if str(signal_present) == "1" else MediaPlayerState.IDLE

@property
def source(self) -> str | None:
return self._source
Expand Down

0 comments on commit a70cc25

Please sign in to comment.