add clear queue command
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Tue, 24 Nov 2020 15:17:26 +0000 (16:17 +0100)
committerMarcel van der Veldt <m.vanderveldt@outlook.com>
Tue, 24 Nov 2020 15:17:26 +0000 (16:17 +0100)
music_assistant/managers/players.py
requirements.txt

index 2dc1e1a72a62d6a295170e5974c3be1dfdeec83b..df367b469e3d7fc8c4a2f281bde63439618580b0 100755 (executable)
@@ -633,6 +633,20 @@ class PlayerManager:
             return
         return await player_queue.async_set_repeat_enabled(enable_repeat)
 
+    @api_route("players/:queue_id/queue/cmd/clear")
+    async def async_player_queue_cmd_clear(
+        self, queue_id: str, enable_repeat: bool = False
+    ):
+        """
+        Clear all items in player's queue.
+
+            :param queue_id: player_id of the playerqueue to handle the command.
+        """
+        player_queue = self.get_player_queue(queue_id)
+        if not player_queue:
+            return
+        return await player_queue.async_clear()
+
     # OTHER/HELPER FUNCTIONS
 
     async def async_get_gain_correct(
@@ -653,13 +667,3 @@ class PlayerManager:
             gain_correct = target_gain - track_loudness
         gain_correct = round(gain_correct, 2)
         return gain_correct
-
-    # async def __handle_websocket_player_control_event(self, msg, msg_details):
-    #     """Handle player controls over the websockets api."""
-    #     if msg in [EVENT_REGISTER_PLAYER_CONTROL, EVENT_PLAYER_CONTROL_UPDATED]:
-    #         # create or update a playercontrol registered through the websockets api
-    #         control = PlayerControl(**msg_details)
-    #         await self.async_update_player_control(control)
-    #         # send confirmation to the client that the register was successful
-    #         if msg == EVENT_PLAYER_CONTROL_REGISTERED:
-    #             self.mass.signal_event(EVENT_PLAYER_CONTROL_REGISTERED, control)
index 10001700df9b7767e6088be7b61ae3328b1dc1b5..cb48efd6774a6a8dd459b6d06379e5f53d437e0f 100644 (file)
@@ -19,4 +19,4 @@ passlib==1.7.4
 cryptography==3.2
 ujson==4.0.1
 mashumaro==1.13
-repath==0.9.0
+