Exemple #1
0
        //Sets up the TextBlocks on the page by getting the song information and lyrics from the MusixMatch API
        private async void SetInfoViewModelAsync(String trackId)
        {
            Retriever             retriever = new Retriever();
            MusicFromIdRootObject music     = await retriever.GetMusic(sharedData.CommonTrackId);

            LyricsRootObject lyrics = await retriever.GetLyrics(sharedData.TrackId);

            //Assigning TextBlock text to match song's info
            infoViewModel = new InfoViewModel()
            {
                AlbumName    = music.message.body.track.album_name,
                TrackName    = music.message.body.track.track_name,
                ArtistName   = music.message.body.track.artist_name,
                LyricsString = lyrics.message.body.lyrics.lyrics_body,
            };
            Title.Text     = infoViewModel.TrackName + " by " + infoViewModel.ArtistName;
            AlbumName.Text = "Album: " + infoViewModel.AlbumName;
            Lyrics.Text    = infoViewModel.LyricsString;
            if (Lyrics.Text.Equals(""))
            {
                Lyrics.Text = "No lyrics available";
            }
            //Links to YT and Spotify
            YouTubeButton.NavigateUri = new Uri("https://www.youtube.com/results?search_query=" + Title.Text);
            SpotifyButton.NavigateUri = new Uri("https://open.spotify.com/search/results/" + Title.Text);
        }
Exemple #2
0
        //Takes the input from the user and runs a search based on them. Takes the results and places them in a collection that can be data binded later. Takes the user to the results page.
        private async void Search_Click(object sender, RoutedEventArgs e)
        {
            sharedData.isAdvancedSearch = false;
            sharedData.SearchBoxTerm    = SearchBox.Text;

            String SearchTerm = SearchBox.Text;
            MusicSearchRootObject musicSearchRootObject = new MusicSearchRootObject();
            Retriever             retriever             = new Retriever();

            //Errors if things are missing
            if (SearchOptions.Content.Equals("Select"))
            {
                WarningBlock.Text = "Please select a search option";
                return;
            }
            if (SearchTerm.Equals(""))
            {
                WarningBlock.Text = "Please enter a search term";
                return;
            }

            WarningBlock.Text = "";

            //Calls API for root objects
            if (SearchOptions.Content.Equals("Artist"))
            {
                sharedData.isArtistSearch = true;
                musicSearchRootObject     = await retriever.GetTrackSearchResults(SearchTerm, "", false, false);
            }
            else
            {
                sharedData.isArtistSearch = false;
                musicSearchRootObject     = await retriever.GetTrackSearchResults(SearchTerm, "", false, true);
            }

            sharedData.Music.Clear();
            sharedData.SearchTerm = SearchTerm;

            SearchResults = musicSearchRootObject.message.body.track_list;
            //Making the observable collection of the results for the results page from the root object
            foreach (TrackList trackList in SearchResults)
            {
                MusicViewModel music = new MusicViewModel()
                {
                    TrackName     = trackList.track.track_name,
                    TrackId       = "" + trackList.track.track_id,
                    CommonTrackId = "" + trackList.track.commontrack_id,
                    ArtistName    = trackList.track.artist_name
                };
                sharedData.Music.Add(music);
            }

            this.Frame.Navigate(typeof(ResultsPage), sharedData);
        }
Exemple #3
0
        //Same as previous method, just for advanced search.
        private async void AdvancedSearch_Click(object sender, RoutedEventArgs e)
        {
            sharedData.isAdvancedSearch        = true;
            sharedData.AdvancedSearchBoxTrack  = AdvancedSearchTrack.Text;
            sharedData.AdvancedSearchBoxArtist = AdvancedSearchArtist.Text;

            MusicSearchRootObject musicSearchRootObject = new MusicSearchRootObject();
            Retriever             retriever             = new Retriever();

            if (AdvancedSearchTrack.Text.Equals("") || AdvancedSearchArtist.Text.Equals(""))
            {
                sharedData.noArtistOrTrack = true;
                if (AdvancedSearchTrack.Text.Equals("") && AdvancedSearchArtist.Text.Equals(""))
                {
                    AdvancedWarningBlock.Text = "Please enter a search term";
                    return;
                }
            }
            else
            {
                sharedData.noArtistOrTrack = false;
            }

            AdvancedWarningBlock.Text = "";

            musicSearchRootObject = await retriever.GetTrackSearchResults(AdvancedSearchTrack.Text, AdvancedSearchArtist.Text, true, true);

            sharedData.Music.Clear();

            if (sharedData.noArtistOrTrack)
            {
                sharedData.SearchTerm = AdvancedSearchTrack.Text + AdvancedSearchArtist.Text;
            }
            else
            {
                sharedData.SearchTerm = AdvancedSearchTrack.Text + " by " + AdvancedSearchArtist.Text;
            }

            SearchResults = musicSearchRootObject.message.body.track_list;

            foreach (TrackList trackList in SearchResults)
            {
                MusicViewModel music = new MusicViewModel()
                {
                    TrackName     = trackList.track.track_name,
                    TrackId       = "" + trackList.track.track_id,
                    CommonTrackId = "" + trackList.track.commontrack_id,
                    ArtistName    = trackList.track.artist_name
                };
                sharedData.Music.Add(music);
            }

            this.Frame.Navigate(typeof(ResultsPage), sharedData);
        }