示例#1
0
        /// <summary>
        /// Start program
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button4_Click(object sender, EventArgs e)
        {
            OpenFileDialog openSong = new OpenFileDialog();

            openSong.FileName    = "Search a new song";
            openSong.Filter      = "file mp3|*.mp3";
            openSong.Multiselect = true;
            if (openSong.ShowDialog() == DialogResult.OK)
            {
                axWindowsMediaPlayer1.URL = openSong.FileName;
                routes = openSong.FileNames;
                //Creat your library, the main playlist
                if (comboBox1.Items.Count == 0 || comboBox1.Items.Count == 1)
                {
                    if (comboBox1.Items.Count == 0)
                    {
                        comboBox1.Items.Add("Your library");
                        comboBox1.SelectedIndex = 0;
                        yourLibrary             = new Playlists("Your library", "Your songs");
                        lists.Add(yourLibrary);
                        CreatePlaylist(yourLibrary.name);
                    }
                    else
                    {
                        CreatePlaylist(yourLibrary.name);
                    }
                }
                else
                {
                    CreatePlaylist(comboBox1.Text);
                }
            }
        }
示例#2
0
        /// <summary>
        /// Method to sort using lambda
        /// </summary>
        /// <param name="option"></param>
        private void SortPlaylist(string option)
        {
            Playlists obj;

            if (comboBox1.SelectedIndex.Equals(-1) || comboBox1.SelectedIndex.Equals(0))
            {
                obj = new Playlists("Your library");
            }
            else
            {
                obj = new Playlists(comboBox1.Text);
            }

            foreach (var lists in lists)
            {
                if (lists.name == obj.name)
                {
                    lists.playlist.Sort((song1, song2) =>
                    {
                        int comparenumber = Compare(option, song1, song2);
                        if (comparenumber == 0)
                        {
                            return(Compare(option, song1, song2));
                        }
                        else
                        {
                            return(comparenumber);
                        }
                    });
                }
                PrintPlaylist(lists.playlist);
            }
        }
示例#3
0
 /// <summary>
 /// Method to search a song by its key
 /// </summary>
 /// <param name="key"></param>
 private void SearchSong(string key)
 {
     try
     {
         Playlists obj;
         if (comboBox1.SelectedIndex.Equals(-1) || comboBox1.SelectedIndex.Equals(0)) //it means that is in the main playlist "your library"
         {
             obj = new Playlists("Your library");
         }
         else
         {
             obj = new Playlists(comboBox1.Text);
         }
         SongsProperties element;
         foreach (var lists in lists)
         {
             element          = lists.searching[key.ToLower()];
             listBox1.Visible = true;
             axWindowsMediaPlayer1.Ctlcontrols.stop();
             listBox1.Items.Add(element.artist + " - " + element.nameSong + ".mp3");
             listBox1.Items.Add("Duration: " + element.duration);
             axWindowsMediaPlayer1.URL = element.filePath;
             PrintPlaylist(lists.playlist);
             if (element != null)
             {
                 return;
             }
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Ups, try againg! Make sure the song exist on your library");
     }
 }
示例#4
0
        /// <summary>
        /// Creat playlist
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void newPlaylistToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CreatPlayList newPlaylist = new CreatPlayList(); //New form

            newPlaylist.ShowDialog();
            Playlists newlist = new Playlists(newPlaylist.namelist, newPlaylist.description);

            lists.Add(newlist);
            comboBox1.Items.Add(newPlaylist.namelist);
        }
示例#5
0
        /// <summary>
        /// Supuestamente debe desplegar las canciones de cada playlist
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            Playlists obj = new Playlists(comboBox1.Text, "");

            foreach (var lists in lists)
            {
                if (lists.name == obj.name)
                {
                    PrintPlaylist(lists.playlist);
                    axWindowsMediaPlayer1.Ctlcontrols.stop();
                    break;
                }
            }
        }
示例#6
0
        /// <summary>
        /// Method to add songs to a playlist
        /// </summary>
        /// <param name="fileRoute">Song's path </param>
        /// <param name="actualList">Actual playlist</param>
        private void AddToList(string fileRoute, Playlists actualList)
        {
            SongsProperties newSong;
            string          filename = "", duration = "", songTitle = "", artist = "";

            try
            {
                TagLib.File Mp3file = TagLib.File.Create(fileRoute);
                filename  = Mp3file.Name;
                duration  = Mp3file.Properties.Duration.ToString();
                songTitle = Mp3file.Tag.Title;
                artist    = Mp3file.Tag.FirstAlbumArtist;
                newSong   = new SongsProperties(songTitle, artist, duration, filename);
                actualList.playlist.Add(newSong);
                actualList.searching.Add(songTitle.ToLower(), newSong);
                actualList.routes.Add(fileRoute);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }