Ejemplo n.º 1
0
        private void LoadPlaylists()
        {
            playlists = new List<IPlaylist>();
            playlists.Add(library);

            if (!Directory.Exists(PLAYLISTDIRECTORYPATH))
                Directory.CreateDirectory(PLAYLISTDIRECTORYPATH);

            shuffleQueue = Playlist.Load(SHUFFLEQUEUEFILEPATH, library);
            if (shuffleQueue == null)
            {
                shuffleQueue = new Playlist(library, "Shuffle Queue");
                shuffleQueue.Save();
            }
            playlists.Add(shuffleQueue);

            string[] playlistFiles = Directory.GetFiles(PLAYLISTDIRECTORYPATH, "*.pl", SearchOption.AllDirectories);
            foreach (string playlistPath in playlistFiles)
                if (playlistPath != SHUFFLEQUEUEFILEPATH)
                {
                    Playlist pl = Playlist.Load(playlistPath, library);
                    if (pl != null)
                        playlists.Add(pl);
                }

            playlistFiles = Directory.GetFiles(PLAYLISTDIRECTORYPATH, "*.fpl", SearchOption.AllDirectories);
            foreach (string playlistPath in playlistFiles)
            {
                RatingFilterPlaylist pl = RatingFilterPlaylist.Load(playlistPath, library);
                if (pl != null)
                    playlists.Add(pl);
            }
        }
Ejemplo n.º 2
0
 private void RenamePlaylist()
 {
     this.tempPlaylist = GetPlaylist(playlistGridView.CurrentCell.Value.ToString()) as Playlist;
     playlistGridView.BeginEdit(true);
 }
Ejemplo n.º 3
0
        private void CreateNewPlaylist()
        {
            string name = GetNewPlaylistName(false);

            IPlaylist newPlaylist = new Playlist(library, name);
            playlists.Add(newPlaylist);
            SetPlaylistGridView();
            ChangeToPlaylist(newPlaylist);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Load playlist from file. Returns null if it fails:
        /// </summary>
        /// <param name="path"></param>
        /// <param name="library"></param>
        /// <returns></returns>
        public static Playlist Load(String path, Library library)
        {
            Stream stream = null;
            Playlist loadedPlaylist = null;
            try
            {
                stream = File.OpenRead(path);
                XmlSerializer serializer = new XmlSerializer(typeof(Playlist));
                loadedPlaylist = (Playlist)serializer.Deserialize(stream);
            }
            catch
            {
                return null;
            }
            finally
            {
                if (stream != null) stream.Close();
            }
            Playlist pl = new Playlist(library, loadedPlaylist.Name, loadedPlaylist.songPaths);
            library.LibraryChanged += pl.library_LibraryChanged;
            pl.CurrentIndex = loadedPlaylist.CurrentIndex;

            List<string> toBeRemoved = new List<string>();
            foreach (string filePath in pl.songPaths)
                if (!library.PathDictionary.Keys.Contains(filePath))
                    toBeRemoved.Add(filePath);
            foreach (string filePath in toBeRemoved)
                pl.Remove(filePath);

            return pl;
        }