diff --git a/src/linkplay/bridge.py b/src/linkplay/bridge.py index e55c3b5..36ce75f 100644 --- a/src/linkplay/bridge.py +++ b/src/linkplay/bridge.py @@ -130,6 +130,11 @@ async def pause(self) -> None: await self.bridge.request(LinkPlayCommand.PAUSE) self.properties[PlayerAttribute.PLAYING_STATUS] = PlayingStatus.PAUSED + async def stop(self) -> None: + """Stop the current playing track and remove the selected source.""" + await self.bridge.request(LinkPlayCommand.STOP) + self.properties[PlayerAttribute.PLAYING_STATUS] = PlayingStatus.STOPPED + async def toggle(self) -> None: """Start playing if the player is currently not playing. Stops playing if it is.""" await self.bridge.request(LinkPlayCommand.TOGGLE) diff --git a/src/linkplay/consts.py b/src/linkplay/consts.py index 2bb793b..31fd4ad 100644 --- a/src/linkplay/consts.py +++ b/src/linkplay/consts.py @@ -79,6 +79,7 @@ class LinkPlayCommand(StrEnum): VOLUME = "setPlayerCmd:vol:{}" PLAYLIST = "setPlayerCmd:playlist:uri:{}" PAUSE = "setPlayerCmd:pause" + STOP = "setPlayerCmd:stop" TOGGLE = "setPlayerCmd:onepause" EQUALIZER_MODE = "setPlayerCmd:equalizer:{}" LOOP_MODE = "setPlayerCmd:loopmode:{}" diff --git a/tests/linkplay/test_bridge.py b/tests/linkplay/test_bridge.py index ff364d7..4367e62 100644 --- a/tests/linkplay/test_bridge.py +++ b/tests/linkplay/test_bridge.py @@ -173,6 +173,17 @@ async def test_player_pause(): assert player.status == PlayingStatus.PAUSED +async def test_player_stop(): + """Tests if the player stop is correctly called.""" + bridge = AsyncMock() + player = LinkPlayPlayer(bridge) + + await player.stop() + + bridge.request.assert_called_once_with(LinkPlayCommand.STOP) + assert player.status == PlayingStatus.STOPPED + + async def test_player_toggle(): """Tests if the player pause is correctly called.""" bridge = AsyncMock()