public async void SwapRepeatState() { var state = CurrentlyPlaying.RepeatState switch { "off" => PlayerSetRepeatRequest.State.Context, "context" => PlayerSetRepeatRequest.State.Track, "track" => PlayerSetRepeatRequest.State.Off, _ => PlayerSetRepeatRequest.State.Off }; try { if (CurrentlyPlaying == null) { return; } //CurrentlyPlaying.RepeatState = state.ToString().ToLower(); var repeat = new PlayerSetRepeatRequest(state) { DeviceId = _deviceId }; await _spotifyClient.Player.SetRepeat(repeat); } catch (APIException) { } }
private void OnToggleRepeat() { SpotifyClient client = SpotifyService.Instance.GetSpotifyClient(); CurrentlyPlayingContext context = this.GetCurrentContext(); if (client != null && context != null) { // Get current shuffle state string currentShuffleState = context.RepeatState; // Determine next shuffle state PlayerSetRepeatRequest.State newState = PlayerSetRepeatRequest.State.Off; switch (currentShuffleState) { case "off": newState = PlayerSetRepeatRequest.State.Track; break; case "track": newState = PlayerSetRepeatRequest.State.Context; break; case "context": newState = PlayerSetRepeatRequest.State.Off; break; default: Debug.LogError($"Unknown Shuffle State '{currentShuffleState}'"); break; } // Build request and send PlayerSetRepeatRequest request = new PlayerSetRepeatRequest(newState); client.Player.SetRepeat(request); } }
Task <bool> IPlayerClient.SetRepeat(PlayerSetRepeatRequest request) => throw new NotImplementedException();