public static Aimp4Playlist UpgradePlaylist(Aimp3Playlist oldPlaylist) { var newPlaylist = new Aimp4Playlist { Name = oldPlaylist.Name, Path = System.IO.Path.ChangeExtension(oldPlaylist.Path, "aimppl4") }; var contentDuration = 0; var contentFiles = 0; var contentSize = 0; foreach (var oldGroup in oldPlaylist.Groups) { var newSongs = new List <Song>(); foreach (var oldSong in oldGroup.Songs) { var newSong = new Aimp4Song(oldSong); newSongs.Add(newSong); contentDuration += newSong.Duration; contentFiles++; contentSize += newSong.Size; } newPlaylist.Groups.Add(new Aimp4Group(oldGroup.Path, newSongs)); } newPlaylist.Summary.Add("ID", oldPlaylist.Id); newPlaylist.Summary.Add("Name", oldPlaylist.Name); newPlaylist.Summary.Add("NameIsAutoSet", "0"); newPlaylist.Summary.Add("ContentDuration", contentDuration.ToString()); newPlaylist.Summary.Add("ContentFiles", contentFiles.ToString()); newPlaylist.Summary.Add("ContentSize", contentSize.ToString()); newPlaylist.Summary.Add("PlaybackCursor", oldPlaylist.Cursor); newPlaylist.Settings.Add("Flags", oldPlaylist.Flags); newPlaylist.Settings.Add("FormatMainLine", "%IF(%R,%R - %T,%T)"); newPlaylist.Settings.Add("FormatSecondLine", "%E :: %H, %B, %S"); newPlaylist.Settings.Add("GroupFormatLine", "%D"); return(newPlaylist); }
private void LoadPlaylists() { lstPlaylists.Items.Clear(); // AIMP3 playlists. foreach (var file in Directory.GetFiles(Settings.Default.PlaylistPath, "*.aimppl")) { var playlist = new Aimp3Playlist(file); lstPlaylists.Items.Add(playlist); } // AIMP4 playlists. foreach (var file in Directory.GetFiles(Settings.Default.PlaylistPath, "*.aimppl4")) { var playlist = new Aimp4Playlist(file); lstPlaylists.Items.Add(playlist); } if (lstPlaylists.Items.Count > 0) { lstPlaylists.Sorted = true; lstPlaylists.SelectedIndex = 0; } }