Ejemplo n.º 1
0
        public Task Load(string path)
        {
            return(Task.Run(() =>
            {
                var dirInfo = new DirectoryInfo(path);
                var files = dirInfo.GetFiles("*.wav");

                if (Items == null)
                {
                    Items = new List <Song>();
                }

                foreach (var item in files)
                {
                    //AudioFile audio = new AudioFile(item.FullName, ReadStyle.Average);
                    SoundPlayer soundPlayer = new SoundPlayer(item.FullName);
                    var artist = new Artist(); // audio.Tag.FirstPerformer);
                    var album = new Album();   // audio.Tag.Album, audio.Tag.Year);

                    Items.Add(new Song {
                        Name = item.Name, Album = album, Artist = artist, /*Duration = audio.Properties.Duration.TotalMinutes*/ Path = item.FullName                 /*, Lirics = audio.Tag.Lyrics*/
                    });
                    SongsListChangedEvent?.Invoke(Items, null, Locked, Volume, Playing);
                }
            }));
        }
Ejemplo n.º 2
0
 public void Clear(List <Song> songList)//AL6-Player1/2-AudioFiles.
 {
     SongsListChangedEvent?.Invoke(songList);
     for (int i = songList.Count - 1; i >= 0; i--)
     {
         songList.RemoveAt(i);
     }
 }
Ejemplo n.º 3
0
        public void Load(string source)
        {
            var dirInfo = new DirectoryInfo(source);

            if (dirInfo.Exists)
            {
                var files = dirInfo.GetFiles();
                foreach (var file in files)
                {
                    var song = new Song
                    {
                        Path = file.FullName,
                        Name = file.Name
                    };
                    Songs.Add(song);
                }
            }

            SongsListChangedEvent?.Invoke(this);
        }
Ejemplo n.º 4
0
        public void FilterByGenre(List <Song> songList)//BL8-Player4/4.FilterByGenre.
        {
            List <Song> filtredList = new List <Song>();

            Console.Write("0-Rock,1-Pop,2-Metalcore,3-Rapcore,4-Jazz,5-Synthwave\n" +
                          "Input literal fo select by genre:");
            int selectGenre  = Convert.ToInt32(Console.ReadLine());
            var selectedSong = from item in songList
                               where (int)item.Genre == selectGenre
                               select new { title = item.Title, duration = item.Duration, like = item.Like, genre = item.Genre };

            foreach (var item in selectedSong)
            {
                filtredList.Add(new Song()
                {
                    Title = item.title, Duration = item.duration, Like = item.like,
                    Genre = item.genre
                });
            }
            ShowList(filtredList);
            SongsListChangedEvent?.Invoke(songList);
        }
Ejemplo n.º 5
0
        public void Load(List <Song> songList)//AL6-Player1/2-AudioFiles.
        {
            Program.SkinForRef.Render("Input path of SongList: ");
            Path = Console.ReadLine();
            List <string> pathList = new List <string>();
            DirectoryInfo DirInfo  = new DirectoryInfo(Path);
            var           j        = DirInfo.EnumerateFiles(".wav").Count();
            var           songs    = from wav in DirInfo.EnumerateFiles()
                                     select wav;

            foreach (var wav in songs)
            {
                pathList.Add(wav.FullName);
            }
            for (int i = 0; i < pathList.Count; i++)
            {
                FileInfo songInfo = new FileInfo(pathList[i]);
                songList.Add(new Song()
                {
                    Title = songInfo.Name, Path = songInfo.FullName
                });
            }
            SongsListChangedEvent?.Invoke(songList);
        }
Ejemplo n.º 6
0
 public List <Song> Shuffled(List <Song> songList)
 {
     SongsListChangedEvent?.Invoke(songList);
     songList = ExtensionClass.Shuffle(songList);
     return(songList);
 }
Ejemplo n.º 7
0
 public List <Song> Sort(List <Song> songList)
 {
     SongsListChangedEvent?.Invoke(songList);
     songList = ExtensionClass.SortByTitle(songList);
     return(songList);
 }