diff --git a/CHANGELOG.md b/CHANGELOG.md index 3cc9909..76cc32b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,11 @@ - "woofer" feature - "soundmode" feature - "eq" feature +- added `media_player` support for next and previous track + +### Changed + +- Fixed state, also displaying "playing" and "paused" values ## [0.3.2] Fix division by zero diff --git a/custom_components/samsung_soundbar/api_extension/SoundbarDevice.py b/custom_components/samsung_soundbar/api_extension/SoundbarDevice.py index f6d1b77..d724a4e 100644 --- a/custom_components/samsung_soundbar/api_extension/SoundbarDevice.py +++ b/custom_components/samsung_soundbar/api_extension/SoundbarDevice.py @@ -194,7 +194,15 @@ def device_name(self): @property def state(self) -> str: - return "on" if self.device.status.switch else "off" + if self.device.status.switch: + if self.device.status.playback_status == "playing": + return "playing" + if self.device.status.playback_status == "paused": + return "paused" + else: + return "on" + else: + return "off" async def switch_off(self): await self.device.switch_off(True) @@ -377,6 +385,12 @@ async def media_pause(self): async def media_stop(self): await self.device.stop(True) + async def media_next_track(self): + await self.device.command("main", "mediaPlayback", "fastForward") + + async def media_previous_track(self): + await self.device.command("main", "mediaPlayback", "rewind") + @property def media_app_name(self): detail_status = self.device.status.attributes.get("detailName", None) diff --git a/custom_components/samsung_soundbar/media_player.py b/custom_components/samsung_soundbar/media_player.py index d9cac32..41acca1 100644 --- a/custom_components/samsung_soundbar/media_player.py +++ b/custom_components/samsung_soundbar/media_player.py @@ -33,6 +33,8 @@ | MediaPlayerEntityFeature.TURN_OFF | MediaPlayerEntityFeature.TURN_ON | MediaPlayerEntityFeature.PLAY + | MediaPlayerEntityFeature.NEXT_TRACK + | MediaPlayerEntityFeature.PREVIOUS_TRACK | MediaPlayerEntityFeature.STOP | MediaPlayerEntityFeature.SELECT_SOUND_MODE ) @@ -177,6 +179,12 @@ async def async_media_play(self): async def async_media_pause(self): await self.device.media_pause() + async def async_media_next_track(self): + await self.device.media_next_track() + + async def async_media_previous_track(self): + await self.device.media_previous_track() + async def async_media_stop(self): await self.device.media_stop()