Ejemplo n.º 1
0
        private void SearchX(string startingDirectory,Album _Album)
        {
            DirectoryInfo X = new DirectoryInfo(startingDirectory);
            try
            {
                foreach (FileInfo File in X.GetFiles())
                {
                    if (File.FullName.EndsWith(".mp3"))
                    {
                        TagLib.Mpeg.File Sn = new TagLib.Mpeg.File(File.FullName);

                            Song _Song = new Song();
                            _Song.Name = Sn.Tag.Title;
                            _Song.Artist = Sn.Tag.Artists[0];
                            _Album.Songs.Add(_Song);
                            _Song.Type = "application/mp3";
                            _Song.File = File.FullName;

                    }
                    else if (File.FullName.EndsWith(".txt"))
                    {

                        {
                            Song _Song = new Song();
                            _Song.Name = File.Name;
                            _Song.Artist = "Unknown";
                            _Album.Songs.Add(_Song);
                            _Song.Type = "text";
                            _Song.File = File.FullName;
                        }
                    }
                }

                foreach (DirectoryInfo Dir in X.GetDirectories())
                {
                    SearchX(Dir.FullName, _Album);
                }
                }
            catch
            {
            }
        }
Ejemplo n.º 2
0
        private void listView1_DoubleClick(object sender, EventArgs e)
        {
            if (listView1.SelectedItems != null)
            {
                Song F = GetSong(listView1.SelectedItems[0].SubItems[1].Text, listView1.SelectedItems[0].SubItems[2].Text);
                if (F != null)
                {

                    CurrentSong = F;
                }
                Mark();
            }
            listView1.SelectedItems.Clear();
            if (CurrentSong.Type == "application/mp3")
            {
                player.URL = CurrentSong.File;

                player.Ctlcontrols.play();
            }
            else if(CurrentSong.Type == "text")
            {
                using(StreamReader SR = new StreamReader(CurrentSong.File))
                {
                    richTextBox1.Text = SR.ReadToEnd();
                    SR.Close();
                }
            }
            // trackBar1.Maximum = (int)player.currentMedia.duration;
        }
Ejemplo n.º 3
0
        private void Search(string startingDirectory)
        {
            DirectoryInfo X = new DirectoryInfo(startingDirectory);
            Collection _Collection = new Collection();
            Artist _Artist = new Artist();
            Album _Album = new Album();
            _Collection.Artists.Add(_Artist);
            _Artist.Albums.Add(_Album);
            Collections.Add(_Collection);
            try
            {
                foreach (FileInfo _File in X.GetFiles())
                {
                    if (_File.FullName.EndsWith(".mp3"))
                    {
                        TagLib.Mpeg.File Sn = new TagLib.Mpeg.File(_File.FullName);

                        Song _Song = new Song();
                        _Song.Name = Sn.Tag.Title;
                        _Song.Artist = Sn.Tag.Artists[0];
                        _Album.Songs.Add(_Song);
                        _Song.Type = "application/mp3";
                        _Song.File = _File.FullName;

                    }
                    else if (_File.FullName.EndsWith(".txt"))
                    {

                        {
                            Song _Song = new Song();
                            _Song.Name = _File.Name;
                            _Song.Artist = _File.DirectoryName;

                            _Album.Songs.Add(_Song);
                            _Song.Type = "text";
                            _Song.File = _File.FullName;
                        }
                    }
                    else if (_File.Extension == "exe")
                    {
                        Song _Song = new Song();
                        _Song.Artist = (_File.DirectoryName);
                        _Song.Name = _File.Name;
                        _Song.Type="application/exe";
                        _Album.Songs.Add(_Song);
                    }
                }

                foreach (DirectoryInfo Dir in X.GetDirectories())
                {
                    SearchX(Dir.FullName, _Album);
                }
            }
            catch
            {
            }
            List();
        }
Ejemplo n.º 4
0
        public void LoadCollection(string fileName)
        {
            this.collections.Clear();
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(fileName);
            if (xmlDoc.DocumentElement.Name == "collection")
            {
                Collection _Collection = new Collection();
                _Collection.Name = xmlDoc.GetElementsByTagName("name")[0].InnerText;
                XmlNodeList xnlArtists = xmlDoc.GetElementsByTagName("artist");

                foreach (XmlElement Artist in xnlArtists)
                {
                    Artist _Artist = new Artist();
                    _Artist.Name = Artist.GetAttribute("name");
                    XmlNodeList xnlAlbums = Artist.GetElementsByTagName("album");
                    foreach (XmlElement xeAlbum in xnlAlbums)
                    {
                        Album _Album = new Album();
                        _Album.Name = xeAlbum.GetAttribute("name");
                        XmlNodeList xnlSongs = xeAlbum.GetElementsByTagName("song");
                        foreach (XmlElement XeSong in xnlSongs)
                        {
                            Song R = new Song();
                            R.Name = XeSong.GetAttribute("name");
                            R.Artist = XeSong.GetAttribute("artist");
                            R.File = XeSong.GetAttribute("path");
                            R.Type = XeSong.GetAttribute("type");
                            try
                            {
                                R.Number = int.Parse(XeSong.GetAttribute("number"));
                            }
                            catch
                            {
                                R.Number = 0;
                            }
                            _Album.Songs.Add(R);
                        }
                        _Artist.Albums.Add(_Album);
                    }
                    _Collection.Artists.Add(_Artist);
                }
                collections.Add(_Collection);
                List();
            }
            else if (xmlDoc.DocumentElement.Name == "rss")
            {
                Collection SR = new Collection();
                SR.Name = xmlDoc.GetElementsByTagName("title")[0].InnerText;
                XmlNodeList Items = xmlDoc.GetElementsByTagName("item");
                string Author = xmlDoc.GetElementsByTagName("copyright")[0].InnerText;
                Artist X = new Artist();
                X.Name = Author;
                SR.Artists.Add(X);
                Album _Album = new Album();
                _Album.Name = SR.Name;
                X.Albums.Add(_Album);
                int i = 0;
                foreach (XmlElement Item in Items)
                {
                    XmlNode Enclosure = Item.GetElementsByTagName("enclosure")[0];
                    Song S = new Song();
                    S.Name = Item.GetElementsByTagName("title")[0].InnerText;
                    S.Artist = Author;
                    S.File = Enclosure.Attributes["url"].InnerText;
                    S.Number = i;
                    S.Type = "application/mp3";
                    _Album.Songs.Add(S);
                    i++;
                }
                Collections.Add(SR);
            }
            List();
        }