public override async Task <SkillResponse> HandleIntent(SkillRequest skillRequest, IntentRequest intentRequest, ILambdaContext context) { await SpotifyClient.ResumePlaybackAsync(offset : ""); return(ReturnEmptySkillResponse()); }
public override async Task <SkillResponse> HandleIntent(SkillRequest skillRequest, IntentRequest intentRequest, ILambdaContext context) { var genreName = intentRequest.GetSlotValue("GenreNameSlot"); var items = await SpotifyClient.SearchItemsAsync($"genre:{genreName}", SearchType.Track); if (items.HasError()) { return(TellWithoutEnding("There was an error with searching for the genre")); } if (!items.Tracks.Items.Any()) { return(TellWithoutEnding($"Sorry. Couldn't find any songs for the {genreName}, genre")); } var firstTrack = items.Tracks.Items.Shuffle().FirstOrDefault(); if (firstTrack == null || firstTrack.HasError()) { return(TellWithoutEnding("There was an error with shuffling the tracks")); } await SpotifyClient.ResumePlaybackAsync("", "", new List <string> { firstTrack.Uri }, ""); return(TellWithoutEnding( $"Surprising you with the following song: {firstTrack.Name}")); }
public override async Task <SkillResponse> HandleIntent(SkillRequest skillRequest, IntentRequest intentRequest, ILambdaContext context) { var session = skillRequest.Session; var categoryId = session.GetSessionValue <string>("CategoryId"); if (string.IsNullOrEmpty(categoryId)) { return(TellWithoutEnding("Please specify a category first")); } var playlists = await SpotifyClient.GetCategoryPlaylistsAsync(categoryId); var shuffled = playlists.Playlists.Items.Shuffle(); var shuffledPlaylist = shuffled.FirstOrDefault(); if (shuffledPlaylist == null) { return(TellWithoutEnding("There was an error with shuffling the playlist")); } await SpotifyClient.ResumePlaybackAsync("", shuffledPlaylist.Uri, null, ""); return(TellWithoutEnding($"Playing playlist named: {shuffledPlaylist.Name}")); }
public override async Task <SkillResponse> HandleIntent(SkillRequest skillRequest, IntentRequest intentRequest, ILambdaContext context) { var session = skillRequest.Session; var playlistUri = session.GetSessionValue <string>("PlaylistUri"); if (string.IsNullOrEmpty(playlistUri)) { return(TellWithoutEnding("Please specify a playlist first")); } await SpotifyClient.ResumePlaybackAsync("", playlistUri, null, ""); return(ReturnEmptySkillResponse()); }