コード例 #1
0
ファイル: Search.cs プロジェクト: cwsterling/echonest-sharp
        public Task<SearchResponse> ExecuteAsync(SearchArgument argument)
        {
            argument.ApiKey = ApiKey;
            argument.BaseUrl = Url;

            return ExecuteAsync<SearchResponse>(argument.ToString());
        }
コード例 #2
0
ファイル: Search.cs プロジェクト: cwsterling/echonest-sharp
        public SearchResponse Execute(SearchArgument argument)
        {
            argument.ApiKey = ApiKey;
            argument.BaseUrl = Url;

            return Execute<SearchResponse>(argument.ToString());
        }
コード例 #3
0
        public Task <SearchResponse> ExecuteAsync(SearchArgument argument)
        {
            argument.ApiKey  = ApiKey;
            argument.BaseUrl = Url;

            return(ExecuteAsync <SearchResponse>(argument.ToString()));
        }
コード例 #4
0
        public SearchResponse Execute(SearchArgument argument)
        {
            argument.ApiKey  = ApiKey;
            argument.BaseUrl = Url;

            return(Execute <SearchResponse>(argument.ToString()));
        }
コード例 #5
0
        private void FetchPreview()
        {
            using (var session = new EchoNestSession(EchoNestModule.ApiKey))
            {
                SearchArgument arg = new SearchArgument();
                FillTermList(SelectedMoods, arg.Moods);
                FillTermList(SelectedStyles, arg.Styles);
                arg.MinFamiliarity = ArtistFamiliarity.Minimum;
                arg.MinHotttnesss = ArtistHotness.Minimum;

                SearchResponse response = session.Query<Search>().Execute(arg);

                if (response != null && response.Status.Code == ResponseCode.Success)
                {
                    PreviewArtistList = response.Artists;
                }
                else
                {
                    PreviewArtistList = null;
                }
            }
        }
コード例 #6
0
        private void ExecuteStartRadio()
        {
            Task.Factory.StartNew(() =>
            {
                SelectedMoods.ForEach(s => s.Count = s.Count + 1);
                SelectedStyles.ForEach(s => s.Count = s.Count + 1);

                using (var session = _documentStore.OpenSession())
                {
                    foreach (var selectedStyle in SelectedStyles)
                    {
                        var styleTerm = session.Load<StyleTerm>(selectedStyle.ID);

                        if (styleTerm != null)
                        {
                            styleTerm.Count = selectedStyle.Count;
                            session.Store(styleTerm);
                        }
                    }

                    foreach (var selectedMood in SelectedMoods)
                    {
                        var styleTerm = session.Load<MoodTerm>(selectedMood.ID);

                        if (styleTerm != null)
                        {
                            styleTerm.Count = selectedMood.Count;
                            session.Store(styleTerm);
                        }
                    }

                    session.SaveChanges();
                }
            })
            .ContinueWith(task =>
            {
                if (task.Exception != null)
                {
                    _logger.Log(task.Exception.ToString(), Category.Exception, Priority.Medium);
                }
            });

            Task.Factory.StartNew(() =>
            {
                using (_loadingIndicatorService.EnterLoadingBlock())
                {
                    using (var session = new EchoNestSession(EchoNestModule.ApiKey))
                    {
                        SearchArgument arg = new SearchArgument();
                        FillTermList(SelectedMoods, arg.Moods);
                        FillTermList(SelectedStyles, arg.Styles);
                        arg.MinFamiliarity = ArtistFamiliarity.Minimum;
                        arg.MinHotttnesss = ArtistHotness.Minimum;

                        var response = session.Query<Search>().Execute(arg);

                        if (response == null)
                        {
                            _toastService.Show("Unable to generate playlist");
                            return;
                        }

                        if (response.Status.Code == ResponseCode.Success && response.Artists.Count > 0)
                        {
                            StaticArgument arg2 = new StaticArgument();
                            arg2.Results = 75;
                            FillTermList(SelectedMoods, arg2.Moods);
                            FillTermList(SelectedStyles, arg2.Styles);
                            arg2.Type = "artist-radio";
                            arg2.Artist.Add(response.Artists[0].Name);
                            arg2.MinTempo = Tempo.Minimum;
                            arg2.MinLoudness = Loudness.Minimum;
                            arg2.MinDanceability = Danceability.Minimum;
                            arg2.MinEnergy = Energy.Minimum;
                            arg2.ArtistMinFamiliarity = ArtistFamiliarity.Minimum;
                            arg2.ArtistMinHotttnesss = ArtistHotness.Minimum;
                            arg2.SongMinHotttnesss = SongHotness.Minimum;

                            _radio.Play(new StyleTrackStream(arg2, _radio, _toastService));
                        }
                        else
                        {
                            if (response.Artists != null && response.Artists.Count == 0)
                            {
                                // TODO : Localize
                                _toastService.Show("Unable to find songs matching the current criterias");
                            }
                            else
                            {
                                _toastService.Show("EchoNest : " + response.Status.Message);
                            }
                        }
                    }
                }
            })
            .ContinueWith(task =>
            {
                if (task.Exception != null)
                {
                    _logger.Log(task.Exception.ToString(), Category.Exception, Priority.Medium);
                }
            });
        }