Esempio n. 1
0
        public mpInterface.IMediaPlayList LoadPlayListFromFile(string playlist_path)
        {
            if (playlist_path == null)
            {
                throw new ArgumentNullException("playlist path is null");
            }

            if (System.IO.File.Exists(playlist_path) == false)
            {
                throw new ArgumentException("playlist file does not exist.");
            }

            var playlist = new MediaPlayList(this);

            using (var fs = System.IO.File.OpenRead(playlist_path))
                using (var reader = System.Xml.XmlReader.Create(fs))
                {
                    while (reader.Read())
                    {
                        if (reader.IsStartElement(XML_Constant.PlayList_MediaElement))
                        {
                            if (reader.AttributeCount == XML_Constant.PlayList_AttributeCount)
                            {
                                string media_path = reader.GetAttribute(XML_Constant.PlayList_MediaPathAttribute);
                                if (media_path != null && System.IO.File.Exists(media_path))
                                {
                                    playlist.Add(media_path);
                                }
                            }
                        }
                    }
                }
            return(playlist);
        }
Esempio n. 2
0
        public mpInterface.IMediaPlayList CreateNewPlayList(params string[] media_paths)
        {
            var playlist = new MediaPlayList(this);

            if (media_paths != null && media_paths.Length > 0)
            {
                foreach (var mediapath in media_paths)
                {
                    playlist.Add(mediapath);
                }
            }

            return(playlist);
        }