예제 #1
0
 /// <summary>
 /// Add a song to the list Songs
 /// </summary>
 /// <param name="song">The Song to add to the list</param>
 public void Add(Song song)
 {
     if (!songs.Contains(song))
     {
         songs.Add(song);
     }
 }
예제 #2
0
파일: Artist.cs 프로젝트: grasmanek94/SE21
 /// <summary>
 /// Add a Song to the Artist
 /// </summary>
 /// <param name="song">Song from Artist</param>
 public void Add(Song song)
 {
     if (!songs.Contains(song))
     {
         song.Preformer = this;
         songs.Add(song);
     }
 }
예제 #3
0
 /// <summary>
 /// Add a song to the playlist
 /// </summary>
 /// <param name="song">The song to add</param>
 public void Add(Song song)
 {
     //if 'Contains' is not allowed:
     //if(!Present(song))
     if (!songs.Contains(song))
     {
         songs.Add(song);
     }
 }
예제 #4
0
        /// <summary>
        /// Construct the Music Player
        /// </summary>
        public MusicPlayer()
        {
            artists = new List<Artist>();
            songs = new List<Song>();
            playlists = new List<Playlist>();

            wplayer = new WMPLib.WindowsMediaPlayer();

            currentlyPlaying = null;
            currentlyPlayingList = null;
        }
예제 #5
0
 public Song[] SortSongs(Song[] songs, int index)
 {
     switch (index)
     {
         case -1:
             return songs;
         case 0:
             return songs.OrderBy(s => s.Path).OrderByDescending(s => s.CreationTime).ToArray();
         case 1:
             return songs.OrderBy(s => s.Path).OrderBy(s => s.Title).ToArray();
         case 2:
             return songs.OrderBy(s => s.Path).OrderBy(s => s.Artist).ToArray();
     }
     return null;
 }
예제 #6
0
 /// <summary>
 /// Plays the first or next song in the playlist
 /// </summary>
 /// <returns>The song that is playing, if nothing is playing returns null</returns>
 public Song PlayFirstOrNextSong()
 {
     if (currentlyPlaying == null || !songs.Contains(currentlyPlaying))
     {
         if (songs.Count() > 0)
         {
             currentlyPlaying = songs.ElementAt(0);
         }
         else
         {
             currentlyPlaying = null;
         }
     }
     else
     {
         if (songs.Contains(currentlyPlaying))
         {
             currentlyPlaying = songs.ElementAt(songs.IndexOf(currentlyPlaying) + 1);
         }
     }
     return currentlyPlaying;
 }
예제 #7
0
        public static MusicCollection GetSongs(this Client client)
        {
            IXPFile request = new IXPFile();
            request.NetworkFunction = "com.projectgame.music.music.getsongs";
            IXPFile response = client.IXPRequest(request);

            MusicCollection musicCollection = new MusicCollection();
            int artistCount = int.Parse(response.GetInfoValue("artist_count"));

            for(int currentArtistIndex = 0; currentArtistIndex < artistCount; currentArtistIndex++) {
                int artistID = int.Parse(response.GetInfoValue("artist_" + currentArtistIndex + "_id"));
                string artistName = response.GetInfoValue("artist_" + currentArtistIndex + "_name");
                Artist artist = new Artist(artistID, artistName);
                musicCollection.Artists.Add(artist);

                int albumCount = int.Parse(response.GetInfoValue("artist_" + currentArtistIndex + "_album_count"));

                for(int currentAlbumIndex = 0; currentAlbumIndex < albumCount; currentAlbumIndex++) {
                    int albumID = int.Parse(response.GetInfoValue("artist_" + currentArtistIndex + "_album_" + currentAlbumIndex + "_id"));
                    string albumName = response.GetInfoValue("artist_" + currentArtistIndex + "_album_" + currentAlbumIndex + "_name");
                    Album album = new Album(albumID, albumName);
                    artist.Albums.Add(album);

                    int songCount = int.Parse(response.GetInfoValue("artist_" + currentArtistIndex + "_album_" + currentAlbumIndex + "_song_count"));

                    for(int currentSongIndex = 0; currentSongIndex  < songCount; currentSongIndex++) {
                        int songID = int.Parse(response.GetInfoValue("artist_" + currentArtistIndex + "_album_" + currentAlbumIndex + "_song_" + currentSongIndex + "_id"));
                        string songName = response.GetInfoValue("artist_" + currentArtistIndex + "_album_" + currentAlbumIndex + "_song_" + currentSongIndex + "_name");
                        Song song = new Song(songID, songName);
                        album.Songs.Add(song);
                    }
                }
            }

            return musicCollection;
        }
예제 #8
0
 /// <summary>
 /// Stop playing the playlist
 /// </summary>
 public void StopPlaying()
 {
     currentlyPlaying = null;
 }
예제 #9
0
 /// <summary>
 /// Remove a song from the playlist
 /// </summary>
 /// <param name="song">The song to remove</param>
 public void Remove(Song song)
 {
     //if 'Contains' is not allowed:
     //if(Present(song))
     if (songs.Contains(song))
     {
         songs.Remove(song);
     }
 }
예제 #10
0
        private void btnAddSong_Click(object sender, EventArgs e)
        {
            if(tbName.TextLength < 1)
            {
                MessageBox.Show("De naam van de song mag niet leeg zijn!");
                return;
            }

            if (dtpDate.Value >= DateTime.Now)
            {
                MessageBox.Show("Datum moet in het verleden zijn!");
                return;
            }

            if (lbArtists.SelectedItem == null)
            {
                MessageBox.Show("Selecteer een artiest!");
                return;
            }

            if(tbFilePath.TextLength < 1)
            {
                MessageBox.Show("Het opgegeven bestand bestaat niet of is geen muziek bestand!");
                return;
            }

            FileInfo fi = new FileInfo(tbFilePath.Text);
            if (!fi.Exists || fi.Extension.CompareTo(".mp3") != 0)
            {
                MessageBox.Show("Het opgegeven bestand bestaat niet of is geen mp3 bestand!");
                return;
            }

            foreach (Song s in musicplayer.Songs())
            {
                if (s.PathOfFile == tbFilePath.Text)
                {
                    MessageBox.Show("Song bestaat al!");
                    return;
                }
            }

            Song song = new Song(tbName.Text, dtpDate.Value.Year, (Artist)lbArtists.SelectedItem, tbFilePath.Text);
            if (rtbLyrics.TextLength > 0)
            {
                song.Lyrics = rtbLyrics.Text;
            }

            musicplayer.Add(song);

            this.Close();
        }
예제 #11
0
        private void SetSongsList(Song[] list, bool sortList, bool changeCurrentPlaylist, bool moveToFirstSong)
        {
            if (list == null || songsListBlocked)
                return;
            songsListBlocked = true;
            if (!changeCurrentPlaylist)
            {
                if (songsManager.SortSongs(visibleSongs, 0)
                .SequenceEqual(songsManager.SortSongs(list, 0), new Song() as IEqualityComparer<Song>))
                {
                    songsListBlocked = false;
                    return;
                }
                Song[] busyDataGridSongs;
                if (busyDataGrid == playlist1DataGrid)
                    busyDataGridSongs = playlist1Songs;
                else
                    busyDataGridSongs = playlist2Songs;
                if (visibDataGrid != busyDataGrid && songsManager.SortSongs(busyDataGridSongs, 0)
                    .SequenceEqual(songsManager.SortSongs(list, 0), new Song() as IEqualityComparer<Song>))
                {
                    ShowBusyPlaylist();
                    songsListBlocked = false;
                    return;
                }
                busyDataGrid.Visibility = Visibility.Collapsed;
                freeDataGrid.Visibility = Visibility.Visible;
                busyDGSortIndex = sortComboBox.SelectedIndex;
                ((Image)randButton.Content).Source = visibSongsMixed ? new BitmapImage(new Uri(@"pack://*****:*****@"pack://application:,,,/Images/rand.png"));
            }
            if (list == null || list.Length == 0)
            {
                visibleSongs = new Song[0];
                visibDataGrid.Items.Clear();
            }
            else
            {
                Song currSong = new Song();
                if (visibDataGrid == busyDataGrid && visibDataGrid.SelectedIndex != -1
                    && (visibSongsMixed == true || sortList))
                {
                    currSong = (Song)visibDataGrid.SelectedItem;
                    int count = visibDataGrid.Items.Count;
                    int i = 0;
                    while (visibDataGrid.Items.Count != 1)
                    {
                        if (((Song)visibDataGrid.Items[i]).Path != currSong.Path)
                            visibDataGrid.Items.RemoveAt(i);
                        else
                            i++;
                    }
                    var songsList = list.ToList();
                    songsList.Remove(currSong);
                    list = songsList.ToArray();
                }
                else
                    visibDataGrid.Items.Clear();

                Song[] songs = (visibSongsMixed) ? songsManager.MixSongs(list) : (sortList) ?
                    songsManager.SortSongs(list, sortComboBox.SelectedIndex) : list;
                var newSongsList = new List<Song>();
                if (currSong.Path != null)
                    newSongsList.Add(currSong);
                newSongsList.AddRange(songs);
                visibleSongs = newSongsList.ToArray();
                for (int i = 0; i < songs.Length && i < (currSong.Path != null ? numOfSongsToAddWhenScrolling - 1 : numOfSongsToAddWhenScrolling); i++)
                    visibDataGrid.Items.Add(songs[i]);
                if (moveToFirstSong)
                    MoveToFirstSong();
            }
            numOfAudioTextBlock.Content = string.Format("Количество песен в списке: {0}", visibleSongs.Length);
            songsListBlocked = false;
        }
예제 #12
0
        /// <summary>
        /// Handles double clicking on songlist
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Row_DoubleClick(object sender, MouseButtonEventArgs e)
        {
            // stop current playing song
            player.Dispose();
            timer.Stop();

            DataGridRow row = sender as DataGridRow;
            Song s = (Song)row.Item;
            currentlyPlayingSong = s;
            labelSongName.Content = s.Artist + " - " + s.SongName;
            imageAlbumArt.Source = s.Album.GetAlbumArt();

            // next line needed to force ui to update, otherwise the width of the previous label content would be used in the PlayAnimation method
            // works by telling dispatcher to perform a task with less priority than rendering, but no action specified.
            Dispatcher.Invoke(new Action(() => { }), DispatcherPriority.ContextIdle, null); // forces UI to update, this can cause performance issues

            // played the selected song
            player.Initialise(s.FilePath);
            soundSlider.IsEnabled = true;
            soundSlider.Value = 0;
            soundSlider.Maximum = player.SoundSource.Length;
            player.Play();
            player.SoundOut.Volume = (float)volumeSlider.Value;
            timer.Start();

            // show max audio position to right of slider
            TimeSpan ts = player.SoundSource.GetLength();
            labelAudioLength.Content = string.Format("{0}:{1:D2}", ts.Minutes, ts.Seconds); // d2 means 2 decimals so 02 etc
            labelAudioPosition.Content = "0:00";

            // toggle play button icon
            playButtonBrush.Visual = FindResource("appbar_control_pause") as Visual;

            PlayAnimation();
        }
예제 #13
0
 private void DeleteSong(Song song)
 {
     mediaElement.Source = null;
     var dataGrid = busyDataGrid;
     busyDataGrid.SelectedIndex = -1;
     var songs = playlist1Songs.ToList();
     songs.Remove(song);
     playlist1Songs = songs.ToArray();
     songs = playlist2Songs.ToList();
     songs.Remove(song);
     playlist2Songs = songs.ToArray();
     if (dataGrid.Items.Count > 0)
         dataGrid.SelectedIndex = 0;
     if (visibDataGrid == busyDataGrid)
     {
         busyDataGrid.SelectedIndex = -1;
         SetSongsList(busySongs, true, true, true);
     }
     else
     {
         var vSongs = visibleSongs;
         SetSongsList(busySongs, true, true, true);
         SetSongsList(vSongs, true, false, false);
     }
 }
예제 #14
0
 /// <summary>
 /// Creat a playlist
 /// </summary>
 /// <param name="name">Name of the playlist</param>
 public Playlist(string name)
 {
     this.Name = name;
     songs = new List<Song>();
     currentlyPlaying = null;
 }
예제 #15
0
        public static (List <Song>, int, int, int) GetSongsData()
        {
            var minDuration   = 1000;
            var maxDuration   = 0;
            var totalDuration = 0;

            var artist = new Artist();

            artist.Name = "Powerwolf";
            Console.WriteLine(artist.Name);
            Console.WriteLine(Artist.Genre.Techno);

            var artist2 = new Artist("Lordi");

            Console.WriteLine(artist2.Name);
            Console.WriteLine(Artist.Genre.DubStep);

            var artist3 = new Artist("Sabaton");

            Console.WriteLine(artist3.Name);
            Console.WriteLine(Artist.Genre.Classic);

            var album = new Album();

            album.Name = "New Album";
            album.Year = 2018;

            List <Song> songs  = new List <Song>();
            var         random = new Random();

            for (int i = 0; i < 10; i++)
            {
                var song = new Song()
                {
                    Duration = random.Next(1000),
                    Name     = $"New song {i}",
                    Album    = album,
                    Artist   = artist
                };

                songs.Add(song);

                totalDuration += songs[i].Duration;
                if (songs[i].Duration < minDuration)
                {
                    minDuration = song.Duration;
                }

                maxDuration = Math.Max(maxDuration, song.Duration);
            }


            //return new Object[]{ songs , totalDuration, maxDuration, minDuration };

            //return new Tuple<Song[], int, int, int>(songs, totalDuration, maxDuration, minDuration);

            return(songs, totalDuration, maxDuration, minDuration);


            //class Tuplesongsarrayintintint {
            //Song[] Item1;
            //int Item2
            //}
        }
예제 #16
0
 /// <summary>
 /// Plays a MP3 file by the Path of File
 /// </summary>
 /// <param name="song">The song to play, if this is null only stopping the current song will be performed, if not null, the next song will be player</param>
 private void PlayUrl(Song song)
 {
     //the .stop() fixes a bug where the user would switch tracks really fast and the player component would freeze
     wplayer.controls.stop();
     if(song != null)
     {
         wplayer.URL = song.PathOfFile;
         wplayer.controls.play();
     }
 }
예제 #17
0
        /// <summary>
        /// Play a playlist
        /// </summary>
        /// <param name="playlist">The playlist to play</param>
        public void Play(Playlist playlist)
        {
            if(currentlyPlayingList == playlist)
            {
                currentlyPlaying = currentlyPlayingList.PlayFirstOrNextSong();
            }
            else
            {
                if (currentlyPlayingList != null)
                {
                    currentlyPlayingList.StopPlaying();
                }

                currentlyPlayingList = playlist;
                currentlyPlaying = currentlyPlayingList.PlayFirstOrNextSong();
            }

            PlayUrl(currentlyPlaying);
        }
예제 #18
0
        /// <summary>
        /// Play a song
        /// </summary>
        /// <param name="song">The song to play</param>
        public void Play(Song song)
        {
            if (currentlyPlayingList != null)
            {
                currentlyPlayingList.StopPlaying();
                currentlyPlayingList = null;
            }

            currentlyPlaying = song;

            PlayUrl(currentlyPlaying);
        }
예제 #19
0
 public void Add(Song s)
 {
     this.Rows.Add(s.Name, s.Album, s.Artist);
 }
예제 #20
0
        /// <summary>
        /// Adds a new value to the database and lists
        /// </summary>
        /// <param name="filepath">filepath of new song</param>
        public void Add(string filepath)
        {
            // get the key for the filepath
            int key = filepath.GetHashCode();

            databaseConnection.Open();
            // check if key exists in database
            sqlCommand = "select * from music where id=" + key.ToString() + ";";
            command = new SQLiteCommand(sqlCommand, databaseConnection);
            SQLiteDataReader reader = command.ExecuteReader();

            // if key doesn't exist in database
            if (reader.Read() == false)
            {
                Song newSong = new Song(filepath);

                // add the new song to the database
                sqlCommand = "insert into music (id, title, artist, album, genre, filepath) values (" + key + ", @Title, @Artist, @Album, @Genre, @FilePath);";
                command = new SQLiteCommand(sqlCommand, databaseConnection);

                // add these to allow apostrophes' in parameters
                command.Parameters.Add(new SQLiteParameter("Title", newSong.SongName));
                command.Parameters.Add(new SQLiteParameter("Artist", newSong.Artist.ToString()));
                command.Parameters.Add(new SQLiteParameter("Album", newSong.Album.AlbumName));
                command.Parameters.Add(new SQLiteParameter("Genre", newSong.Genre));
                command.Parameters.Add(new SQLiteParameter("FilePath", filepath));
                try
                {
                    command.ExecuteNonQuery();
                }
                catch (SQLiteException e)
                {
                    MessageBox.Show(e.Message);
                }

                // add new song to library, throws exception if dupe key - shouldnt happen though
                try
                {
                    library.Add(key, filepath);

                    if (this.AlbumList.Contains(newSong.Album)) // could try this as find index is not null
                    {
                        // existing album
                        int i = this.AlbumList.FindIndex(x => x.AlbumName == newSong.Album.AlbumName && x.Artist == newSong.Artist);
                        if (i >= 0)
                        {
                            // this is when there is an existing album by the same artist, so add new songs to that album
                            Album existingAlbum = this.AlbumList[i];
                            existingAlbum.Songs.Add(newSong);
                        }
                        else
                        {
                            // this happens when a duplicate album but by a different artist, therefore add the new album to the list
                            this.AlbumList.Add(newSong.Album);
                            Album newlyAddedAlbum = this.AlbumList[this.AlbumList.FindIndex(x => x.AlbumName == newSong.Album.AlbumName && x.Artist == newSong.Artist)];
                            newlyAddedAlbum.Songs.Add(newSong);
                        }
                    }
                    else
                    {
                        // album doesnt exist
                        this.AlbumList.Add(newSong.Album);
                        Album newlyAddedAlbum = this.AlbumList[this.AlbumList.FindIndex(x => x.AlbumName == newSong.Album.AlbumName)];
                        newlyAddedAlbum.Songs.Add(newSong);
                    }

                    // if artist already exists
                    if (!this.ArtistList.ContainsKey(newSong.Artist))
                    {
                        // add song to artist list
                        this.ArtistList.Add(newSong.Artist, newSong.Artist);
                    }
                }
                catch (ArgumentException e)
                {
                    // key already exists
                    MessageBox.Show(e.Message);
                }
            }
            reader.Close();
            databaseConnection.Close();
        }
예제 #21
0
 /// <summary>
 /// Removes a song from the library
 /// </summary>
 /// <param name="s">the song to be removed</param>
 /// <returns>true if it was the last song in the album, false if not (used to determine whether to show grid or not in main window</returns>
 public bool Remove(Song s)
 {
     int key = s.FilePath.GetHashCode();
     // remove from database
     databaseConnection.Open();
     sqlCommand = "delete from music where id=" + s.FilePath.GetHashCode() + ";";
     command = new SQLiteCommand(sqlCommand, databaseConnection);
     command.ExecuteNonQuery();
     databaseConnection.Close();
     // remove from library
     library.Remove(key);
     // remove from album
     int x = AlbumList.FindIndex(a => a.AlbumName == s.Album.AlbumName && a.Artist == s.Album.Artist);
     AlbumList[x].Songs.Remove(s);
     // remove album from the list if there are no more songs
     if (AlbumList[x].Songs.Count == 0)
     {
         // might cause problems if in song view and one album deleted but others are being shown and then user sent back to grid
         AlbumList.RemoveAt(x);
         // if no albums left with the same artist name, remove from the artist list
         if(!AlbumList.Exists(a => a.Artist == s.Artist))
         {
             ArtistList.Remove(s.Artist);
         }
         return true;
     }
     else
         return false;
 }
예제 #22
0
 public Song[] MixSongs(Song[] songs)
 {
     var rand = new Random();
     return songs.OrderBy(f => rand.Next(0, songs.Length)).ToArray();
 }
예제 #23
0
        private void InitializeTestData()
        {
            Artist[] artist = new Artist[4];

            artist[0] = new Artist("artiest 1", DateTime.Now);
            artist[1] = new Artist("artiest 2", DateTime.Now);
            artist[2] = new Artist("artiest 3", DateTime.Now);
            artist[3] = new Artist("artiest 4", DateTime.Now);

            foreach (Artist a in artist)
            {
                musicplayer.Add(a);
            }

            Song[] song = new Song[16];

            song[0] = (new Song("song 1", 2015, artist[0], @"C:\Downloads\Audiomachine - Chronicles 2012\02 - Reaching.mp3"));
            song[1] = (new Song("song 2", 2015, artist[0], @"C:\Downloads\Audiomachine - Chronicles 2012\02 - Reaching.mp3"));
            song[2] = (new Song("song 3", 2015, artist[0], @"C:\Downloads\Audiomachine - Chronicles 2012\02 - Reaching.mp3"));
            song[3] = (new Song("song 4", 2015, artist[0], @"C:\Downloads\Audiomachine - Chronicles 2012\02 - Reaching.mp3"));

            song[4] = (new Song("song 5", 2015, artist[1], @"C:\Downloads\Audiomachine - Chronicles 2012\02 - Reaching.mp3"));
            song[5] = (new Song("song 6", 2015, artist[1], @"C:\Downloads\Audiomachine - Chronicles 2012\02 - Reaching.mp3"));
            song[6] = (new Song("song 7", 2015, artist[1], @"C:\Downloads\Audiomachine - Chronicles 2012\02 - Reaching.mp3"));
            song[7] = (new Song("song 8", 2015, artist[1], @"C:\Downloads\Audiomachine - Chronicles 2012\02 - Reaching.mp3"));

            song[8] = (new Song("song 9", 2015, artist[2], @"C:\Downloads\Audiomachine - Chronicles 2012\02 - Reaching.mp3"));
            song[9] = (new Song("song 10", 2015, artist[2], @"C:\Downloads\Audiomachine - Chronicles 2012\02 - Reaching.mp3"));
            song[10] = (new Song("song 11", 2015, artist[2], @"C:\Downloads\Audiomachine - Chronicles 2012\02 - Reaching.mp3"));
            song[11] = (new Song("song 12", 2015, artist[2], @"C:\Downloads\Audiomachine - Chronicles 2012\02 - Reaching.mp3"));

            song[12] = (new Song("song 13", 2015, artist[3], @"C:\Downloads\Audiomachine - Chronicles 2012\02 - Reaching.mp3"));
            song[13] = (new Song("song 14", 2015, artist[3], @"C:\Downloads\Audiomachine - Chronicles 2012\02 - Reaching.mp3"));
            song[14] = (new Song("song 15", 2015, artist[3], @"C:\Downloads\Audiomachine - Chronicles 2012\02 - Reaching.mp3"));
            song[15] = (new Song("song 16", 2015, artist[3], @"C:\Downloads\Audiomachine - Chronicles 2012\02 - Reaching.mp3"));

            foreach (Song s in song)
            {
                musicplayer.Add(s);
            }

            Playlist[] playlist = new Playlist[2];

            playlist[0] = new Playlist("list 1");
            playlist[1] = new Playlist("list 2");

            for (int p = 0; p < 2; ++p)
            {
                for (int i = 0; i < 8; ++i)
                {
                    playlist[p].Add(song[p * 8 + i]);
                }
            }

            foreach (Playlist p in playlist)
            {
                musicplayer.Add(p);
            }

            UpdateArtistList();
            UpdateSongList();
            UpdatePlayList();
        }
예제 #24
0
        public void LoadLibrary()
        {
            // check database exists
            try
            {
                databaseConnection.Open();

                // load existing database values to lists
                sqlCommand = "select * from music;";
                command = new SQLiteCommand(sqlCommand, databaseConnection);

                SQLiteDataReader reader = command.ExecuteReader();

                while(reader.Read())
                {
                    int key = (int)reader["id"];
                    library.Add(key, (string)reader["filepath"]);

                    Song songToAdd = new Song((string)reader["filepath"]);

                    if(this.AlbumList.Contains(songToAdd.Album)) // could try this as find index is not null
                    {
                        // existing album
                        int i = this.AlbumList.FindIndex(x => x.AlbumName == songToAdd.Album.AlbumName && x.Artist == songToAdd.Artist);
                        if(i >= 0)
                        {
                            // this is when there is an existing album by the same artist, so add new songs to that album
                            Album existingAlbum = this.AlbumList[i];
                            existingAlbum.Songs.Add(songToAdd);
                        }
                        else
                        {
                            // this happens when a duplicate album but by a different artist, therefore add the new album to the list
                            this.AlbumList.Add(songToAdd.Album);
                            Album newlyAddedAlbum = this.AlbumList[this.AlbumList.FindIndex(x => x.AlbumName == songToAdd.Album.AlbumName && x.Artist == songToAdd.Artist)];
                            newlyAddedAlbum.Songs.Add(songToAdd);
                        }

                    }
                    else
                    {
                        // when the album doesnt exist
                        this.AlbumList.Add(songToAdd.Album);
                        Album newlyAddedAlbum = this.AlbumList[this.AlbumList.FindIndex(x => x.AlbumName == songToAdd.Album.AlbumName)];
                        newlyAddedAlbum.Songs.Add(songToAdd);
                    }

                    // if artist already exists
                    if (!this.ArtistList.ContainsKey(songToAdd.Artist))
                    {
                        // add song to artist list
                        this.ArtistList.Add(songToAdd.Artist.ToString(), songToAdd.Artist.ToString());
                    }

                }

                databaseConnection.Close();
            }
            catch(SQLiteException e)
            {
                // database doesnt exist, so create new one.
                MessageBox.Show(e.Message + ". Creating new");
                databaseConnection = CreateNewDatabase();
            }
        }