fix jsonrpc
authormarcelveldt <marcelvanderveldt@MacBook-Silvia.local>
Sat, 26 Oct 2019 08:50:17 +0000 (10:50 +0200)
committermarcelveldt <marcelvanderveldt@MacBook-Silvia.local>
Sat, 26 Oct 2019 08:50:17 +0000 (10:50 +0200)
music_assistant/models/musicprovider.py
music_assistant/models/player.py
music_assistant/models/player_queue.py
music_assistant/music_manager.py
music_assistant/web.py
music_assistant/web/lib/utils.js

index 2cc4c9a2a1f30010eefc00466d739135f741f22e..546a662621ba99eac504e9822c81fce62874c50e 100755 (executable)
@@ -356,10 +356,6 @@ class MusicProvider():
     async def remove_playlist_tracks(self, prov_playlist_id, prov_track_ids):
         ''' remove track(s) from playlist '''
         raise NotImplementedError
-
-    async def get_stream_content_type(self, track_id):
-        ''' return the content type for the given track when it will be streamed'''
-        raise NotImplementedError
     
     async def get_stream_details(self, track_id):
         ''' get streamdetails for a track '''
index ffe81558759c71d02dc8900d09cd936d20818f90..dae9e0d19c55c67eb22363d91cfab60f5718af0c 100755 (executable)
@@ -500,12 +500,11 @@ class Player():
 
     async def volume_set(self, volume_level):
         ''' [PROTECTED] send new volume level command to player '''
-        if isinstance(volume_level, str):
-            if '+' in volume_level or 'up' in volume_level.lower():
-                return await self.volume_up()
-            elif '-' in volume_level or 'down' in volume_level.lower():
-                return await self.volume_down()
         volume_level = try_parse_int(volume_level)
+        if volume_level < 0:
+            volume_level = 0
+        elif volume_level > 100:
+            volume_level = 100
         # handle group volume
         if self.is_group:
             cur_volume = self.volume_level
index a04f26127f7470fa1e66b626308ae42dd097d387..c6703b68a638e1dfcc41c94b9c5fb615444690a6 100755 (executable)
@@ -179,12 +179,13 @@ class PlayerQueue():
         ''' resume previous queue '''
         if self.items:
             prev_index = self.cur_index
-            if self.use_queue_stream:
+            if self.use_queue_stream or not self._player.supports_queue:
                 await self.play_index(prev_index)
             else:
                 # at this point we don't know if the queue is synced with the player
-                # so just to be safe we only send the queue_items from the index
-                await self.load(self._items[prev_index:])
+                # so just to be safe we send the queue_items to the player
+                await self._player.cmd_queue_load(self.items)
+                await self.play_index(prev_index)
         else:
             LOGGER.warning("resume queue requested for %s but queue is empty" % self._player.name)
     
index e1a9d42f63ea86303bfb20cde4047fc68d799e2a..d52bf90dd673434cea6f587de8f66f31bc1215c2 100755 (executable)
@@ -214,6 +214,8 @@ class MusicManager():
                         elif action == 'library_remove':
                             result = await prov.remove_library(prov_item_id, media_type)
                             await self.mass.db.remove_from_library(item.item_id, item.media_type, prov_id)
+                        elif action == 'add_to_playlist':
+                            result = await self.add_playlist_tracks(action_details, [item])
         return result
     
     async def add_playlist_tracks(self, playlist_id, tracks:List[Track]):
@@ -398,4 +400,3 @@ class MusicManager():
             if db_id not in cur_db_ids:
                 await self.mass.db.remove_from_library(db_id, MediaType.Radio, prov_id)
         LOGGER.info("Finished syncing Radios for provider %s" % prov_id)
-
index 87f0d9a1d15cd029995a559a7df9efa9cf13ceba..62798f97243ed3c2ad876e66e1afb0d2a203f750 100755 (executable)
@@ -350,10 +350,10 @@ class Web():
         elif cmd_str == 'playlist index -1':
             await player.previous()
         elif 'mixer volume' in cmd_str and '+' in cmds[2]:
-            volume_level = cmds[2].split('+')[1]
+            volume_level = player.volume_level + int(cmds[2].split('+')[1])
             await player.volume_set(volume_level)
         elif 'mixer volume' in cmd_str and '-' in cmds[2]:
-            volume_level = cmds[2].split('-')[1]
+            volume_level = player.volume_level - int(cmds[2].split('-')[1])
             await player.volume_set(volume_level)
         elif 'mixer volume' in cmd_str:
             await player.volume_set(cmds[2])
index 922471c86f13f0252818314e1a8d2030cfe553d1..2f4b47900e35da0665b610b3371af014e7b71230 100644 (file)
@@ -54,7 +54,7 @@ function toggleLibrary (item) {
             if (action == "/library_remove")
                 item.in_library = []
             else
-            item.in_library = [provider]
+                item.in_library = [provider]
             })
         .catch(error => {
             console.log("error", error);