Beispiel #1
0
 /// <summary>
 /// Add an artist
 /// </summary>
 /// <param name="artist">The Artist to add to the list</param>
 public void Add(Artist artist)
 {
     if (!artists.Contains(artist))
     {
         artists.Add(artist);
     }
 }
Beispiel #2
0
        /// <summary>
        /// Create a song
        /// </summary>
        /// <param name="name">Name of the Song</param>
        /// <param name="year">Year of the Song</param>
        /// <param name="artist">Name of the preformer</param>
        /// <param name="pathOfFile">Path to the file</param>
        public Song(string name, int year, Artist artist, string pathOfFile)
        {
            Name = name;
            Year = year;
            PathOfFile = pathOfFile;
            Preformer = artist;

            artist.Add(this);
        }
        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;
        }
Beispiel #4
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();
        }
Beispiel #5
0
        public static (Song[], int, int, int) GetSongsData()
        {
            var minDuration   = 1000;
            var maxDuration   = 0;
            var totalDuration = 0;

            var artist = new Artist();

            artist.Name  = "Powerwolf";
            artist.Genre = "Metal";

            var artist2 = new Artist("Lordi");

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

            var artist3 = new Artist("Sabaton", "Rock");

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

            var album = new Album();

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

            Song[] songs  = new Song[10];
            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[i] = 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
            //}
        }
 public void Add(Artist artist)
 {
     Artists.Add(artist);
 }
Beispiel #7
0
        private void btnfilePath_Click(object sender, EventArgs e)
        {
            DialogResult result = openFileDialog1.ShowDialog(this);
            if (result == DialogResult.OK || result == DialogResult.Yes)
            {
                tbFilePath.Text = openFileDialog1.FileName;
                if (tbFilePath.TextLength > 0)
                {
                    try
                    {
                        FileInfo fi = new FileInfo(tbFilePath.Text);
                        if (fi.Exists && fi.Extension.CompareTo(".mp3") == 0)
                        {
                            //File OK
                            TagLib.File musicfile = TagLib.File.Create(tbFilePath.Text);
                            if (musicfile.Tag != null)
                            {
                                if (musicfile.Tag.Year != 0)
                                {
                                    dtpDate.Value = new DateTime((int)musicfile.Tag.Year, 1, 1);
                                }
                                if(musicfile.Tag.Title != null)
                                {
                                    tbName.Text = musicfile.Tag.Title;
                                }

                                //toevoegen van artiest
                                Artist creator = null;

                                if (musicfile.Tag.AlbumArtists.Count() != 0 && musicfile.Tag.AlbumArtists[0] != null)
                                {
                                    string artist = musicfile.Tag.AlbumArtists[0];

                                    foreach (Artist a in musicplayer.Artists())
                                    {
                                        if (a.Name == artist)
                                        {
                                            creator = a;
                                            break;
                                        }
                                    }

                                    if (creator == null)
                                    {
                                        creator = new Artist(artist, DateTime.Now);
                                        musicplayer.Add(creator);
                                        UpdateArtistList();
                                    }

                                    lbArtists.SelectedItem = creator;
                                }
                            }
                        }

                    }
                    catch(ArgumentNullException)
                    {

                    }
                    catch (ArgumentException)
                    {

                    }
                }
            }
        }
Beispiel #8
0
        static void Main(string[] args)
        {
            Skin colorSkin   = new ColorSkin(ConsoleColor.Cyan);
            Skin classicSkin = new ClassicSkin();


            var player  = new Player(classicSkin);
            var player2 = new Player(colorSkin);
            //player.Volume = 20;

            var result = GetSongsData();

            var(songs, total, max, min) = result;

            player.Add(songs);
            player2.Add(songs);

            //int min = result.min;
            //int max = result.max;
            //int total = result.total;

            Console.WriteLine($"Min = {min}, max = {max}, total = {total}");

            //            TraceInfo(player);

            player.Play();
            player2.Play();
            //player.Locked();
            //player.Unlock();
            player.VolumeUp();
            Console.WriteLine(player.Volume);

            player.VolumeChange(-300);
            Console.WriteLine(player.Volume);

            player.VolumeChange(300);
            Console.WriteLine(player.Volume);

            /*player.Volume = -25;
             * Console.WriteLine(player.Volume);
             */
            player.Stop();
            player2.Stop();

            List <Song> randSongs = new List <Song>();

            var randSong = CreateSong();

            randSong.LikeMethod();
            Artist artist = new Artist("SomeArtist", Artist.Genre.Classic);

            randSong.Artist = artist;

            var randSong_2 = CreateSong("Go!");

            randSong_2.DisLikeMethod();
            var randSong_3 = CreateSong("Signals", 123);
            var randSong4  = CreateSong("La", 303);
            var randSong_5 = CreateSong("Lala");

            randSong_5.LikeMethod();
            var randSong_6 = CreateSong("NewSong");
            var randSong7  = CreateSong();
            var randSong_8 = CreateSong("Go2!");
            var randSong_9 = CreateSong("Signals2", 1230);
            var randSong10 = CreateSong("La2", 303);

            randSong10.DisLikeMethod();
            var randSong_11 = CreateSong("Lala2");
            var randSong_12 = CreateSong("NewSong2");

            randSongs.Add(randSong);
            randSongs.Add(randSong_2);
            randSongs.Add(randSong_3);
            randSongs.Add(randSong4);
            randSongs.Add(randSong_5);
            randSongs.Add(randSong_6);
            randSongs.Add(randSong7);
            randSongs.Add(randSong_8);
            randSongs.Add(randSong_9);
            randSongs.Add(randSong10);
            randSongs.Add(randSong_11);
            randSongs.Add(randSong_12);

            player.Add(randSongs);
            player2.Add(randSongs);

            player.Play(true);
            player2.Play(true);

            player.Shuffle();
            player2.Shuffle();

            var filteredSongs = FilterByGenre(randSongs, Artist.Genre.Classic);

            foreach (Song song in filteredSongs)
            {
                Console.WriteLine(song.Name.Truncate(3));
            }

            Console.ReadLine();
        }