public ObservableCollection <MusicFileTag> LoadPlaylist(string filePath)
        {
            ObservableCollection <MusicFileTag> NewMusicFileTags = new ObservableCollection <MusicFileTag>();

            Stream fileContentStream = new FileStream(filePath, FileMode.Open);

            M3uContent  content  = new M3uContent();
            M3uPlaylist playlist = content.GetFromStream(fileContentStream);

            List <string> paths = playlist.GetTracksPaths();

            foreach (var file in paths)
            {
                MusicFileTag newMusicFile = AddFile(file);
                if (newMusicFile != null)
                {
                    NewMusicFileTags.Add(newMusicFile);
                }
            }

            return(NewMusicFileTags);
        }
示例#2
0
        private IPlaylist MapToDomain(M3uPlaylist m3uPlaylistBase)
        {
            IPlaylist playlist = null;

            var commentList = ExtractAllComments(m3uPlaylistBase.PlaylistEntries);

            var author    = GetValueFromComment("PLAYLIST-Author", commentList, "NoName");
            var title     = GetValueFromComment("PLAYLIST-Title", commentList, Path.GetFileNameWithoutExtension(m3uPlaylistBase.Path));
            var createdAt = GetValueFromComment("PLAYLIST-CreatedAt", commentList, File.GetCreationTime(m3uPlaylistBase.Path).ToShortDateString());

            List <string> paths = m3uPlaylistBase.GetTracksPaths();

            playlist = new Playlist(title, author, DateTime.Parse(createdAt));
            foreach (var itemPath in paths)
            {
                var playlistItem = _playlistItemFactory.Create(itemPath);
                if (playlistItem != null)
                {
                    playlist.Add(playlistItem);
                }
            }

            return(playlist);
        }