private List <AudioPlayerPlayDirective> AddPlayListDirective(DeezerSearchResp deezer)
        {
            List <AudioPlayerPlayDirective> playlist = new List <AudioPlayerPlayDirective>();

            foreach (var item in deezer.data)
            {
                var c = new AudioPlayerPlayDirective()
                {
                    //PlayBehavior = PlayBehavior.Enqueue,
                    AudioItem = new Alexa.NET.Response.Directive.AudioItem()
                    {
                        Stream = new AudioItemStream()
                        {
                            Url   = item.preview,
                            Token = item.title_short
                        },
                        Metadata = new AudioItemMetadata
                        {
                            Title    = item.album.title,
                            Subtitle = item.title_short,
                            Art      = new AudioItemSources
                            {
                                Sources = new List <AudioItemSource>
                                {
                                    new AudioItemSource
                                    {
                                        Url = item.album.cover_xl
                                    }
                                }
                            },
                            BackgroundImage = new AudioItemSources
                            {
                                Sources = new List <AudioItemSource>
                                {
                                    new AudioItemSource
                                    {
                                        Url = item.album.cover_xl
                                    }
                                }
                            },
                        },
                    }
                };
                playlist.Add(c);
            }
            return(playlist);
        }
        private AudioPlayerPlayDirective AddAudioDirective(DeezerSearchResp deezer)
        {
            var c = new AudioPlayerPlayDirective()
            {
                //PlayBehavior = PlayBehavior.ReplaceAll,
                AudioItem = new Alexa.NET.Response.Directive.AudioItem()
                {
                    Stream = new AudioItemStream()
                    {
                        Url   = deezer.data[0].preview,
                        Token = deezer.data[0].title_short
                    },
                    Metadata = new AudioItemMetadata
                    {
                        Title    = deezer.data[0].album.title,
                        Subtitle = deezer.data[0].title_short,
                        Art      = new AudioItemSources
                        {
                            Sources = new List <AudioItemSource>
                            {
                                new AudioItemSource
                                {
                                    Url = deezer.data[0].album.cover_xl
                                }
                            }
                        },
                        BackgroundImage = new AudioItemSources
                        {
                            Sources = new List <AudioItemSource>
                            {
                                new AudioItemSource
                                {
                                    Url = deezer.data[0].album.cover_xl
                                }
                            }
                        },
                    },
                }
            };

            return(c);
        }
Example #3
0
        public async Task <DeezerSearchResp> SearchDeezer(string query, ILambdaContext context)
        {
            DeezerSearchResp deezer = new DeezerSearchResp();

            try
            { var url = $"https://deezerdevs-deezer.p.rapidapi.com/search?q={query}";
              context.Logger.LogLine($"Attempting to fetch data from {url}");
              var client  = new RestClient(url);
              var request = new RestRequest(Method.GET);
              request.AddHeader("x-rapidapi-host", "deezerdevs-deezer.p.rapidapi.com");
              request.AddHeader("x-rapidapi-key", "f250d8c702msh0c771bf84583dc7p122966jsnb8b46d1aa031");
              IRestResponse response = await client.ExecuteAsync(request);

              deezer = JsonConvert.DeserializeObject <DeezerSearchResp>(response.Content);
              return(deezer); }
            catch (Exception ex)
            {
                context.Logger.LogLine($"\nException: {ex.Message}");
                context.Logger.LogLine($"\nStack Trace: {ex.StackTrace}");
            }
            return(null);
        }