(action: PlayerAction, context: ClientContext)
| 184 | |
| 185 | |
| 186 | async def handle_call(action: PlayerAction, context: ClientContext): |
| 187 | match action["actionName"]: |
| 188 | case "play": |
| 189 | start_index = action["parameters"].get("trackNumber", None) |
| 190 | end_index = 0 |
| 191 | |
| 192 | if start_index is None: |
| 193 | track_range = action["parameters"].get("trackRange", None) |
| 194 | if track_range: |
| 195 | start_index = track_range[0] |
| 196 | end_index = track_range[1] |
| 197 | |
| 198 | if start_index is not None: |
| 199 | if not end_index: |
| 200 | end_index = start_index + 1 |
| 201 | if context.currentTrackList is None: |
| 202 | queue = await context.service.queue() |
| 203 | if queue["queue"]: |
| 204 | tracks = get_tracks_from_result_list(resultItems=queue["queue"]) |
| 205 | context.currentTrackList = tracks |
| 206 | |
| 207 | if context.currentTrackList: |
| 208 | item_uris = [a.uri for a in context.currentTrackList] |
| 209 | await context.service.start_playback( |
| 210 | device_id=context.deviceId, uris=item_uris, offset={"position": start_index} |
| 211 | ) |
| 212 | else: |
| 213 | query = action["parameters"].get("query", None) |
| 214 | album = action["parameters"].get("album", None) |
| 215 | track = action["parameters"].get("trackName", None) |
| 216 | artist = action["parameters"].get("artist", None) |
| 217 | quantity = action["parameters"].get("quantity", 1) |
| 218 | if quantity < 9: |
| 219 | quantity = 1 |
| 220 | |
| 221 | if query: |
| 222 | actionType = action["parameters"].get("itemType", "album") |
| 223 | if actionType == "track": |
| 224 | await play_tracks_with_query(query, quantity, context) |
| 225 | else: |
| 226 | await play_albums_with_query(query, quantity, context) |
| 227 | elif track is not None: |
| 228 | query = 'track:' + track |
| 229 | await play_tracks_with_query(query, quantity, context) |
| 230 | elif album is not None: |
| 231 | query = 'album:' + album |
| 232 | await play_albums_with_query(query, quantity, context) |
| 233 | elif artist is not None: |
| 234 | query = 'artist:' + artist |
| 235 | await play_artist_with_query(query, context) |
| 236 | else: |
| 237 | # Resume playback on default device |
| 238 | await context.service.start_playback(device_id=context.deviceId) |
| 239 | case "status": |
| 240 | await print_status(context) |
| 241 | case "getQueue": |
| 242 | queue = await context.service.queue() |
| 243 | print("Current Queue: ") |
no test coverage detected
searching dependent graphs…