Beispiel #1
0
        private void Button2_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            foreach (var file in openFileDialog1.FileNames)
            {
                var item = _playlistItemFactory.Create(file);
                if (item != null)
                {
                    _playlist.Add(item);
                }
            }
        }
        private void itemsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            openFileDialog1.Filter = "MP3 File (*.mp3)|*.mp3";
            if (openFileDialog1.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            foreach (var file in openFileDialog1.FileNames)
            {
                var item = _playlistItemFactory.Create(file);
                if (item != null)
                {
                    _playlist.Add(item);
                }
            }

            UpdatePlaylistDetails();
            UpdatePlaylistItems();
        }
Beispiel #3
0
        private void AddNewItemToPlaylist_Click(object sender, EventArgs e)
        {
            if (OpenFileDialog1.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            foreach (var file in OpenFileDialog1.FileNames)
            {
                var item = _playlistFactory.Create(file);
                if (item != null)
                {
                    _playlist.Add(item);
                }
            }

            //update view
            DisplayPlaylistDetails(_playlist);
            DisplayPlaylistItems(_playlist);
        }
Beispiel #4
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);
        }