public static PlaylistData LoadXML(string xmlPath) { XElement result = XElement.Load(xmlPath); PlaylistData data = new PlaylistData(); XElement generateTag = result.Element("Generate"); //new XElement("Generate"); data.PlaylistTitle = generateTag.Attribute("play_list_title").Value; data.PlaylistType = (generateTag.Attribute("play_list_type") != null && !string.IsNullOrEmpty(generateTag.Attribute("play_list_type").Value) ? (PlayListType)int.Parse(generateTag.Attribute("play_list_type").Value) : PlayListType.Classic); //generateTag.SetAttributeValue("auto_link", "No"); //generateTag.SetAttributeValue("comment", ""); //generateTag.SetAttributeValue("file_date", DateTime.Now.ToString("ddMMyyyy")); //generateTag.SetAttributeValue("origin", "Piko Traffic Manager"); //generateTag.SetAttributeValue("play_list_title", block.Data.Title); //generateTag.SetAttributeValue("play_list_type", "block"); List <PlaylistElementData> elementsData = new List <PlaylistElementData>(); foreach (XElement playListElement in result.Elements("Event")) { PlaylistElementData elementData = new PlaylistElementData(); elementData.Duration = playListElement.Attribute("event_duration") != null && !string.IsNullOrEmpty(playListElement.Attribute("event_duration").Value) ? (uint)int.Parse(playListElement.Attribute("event_duration").Value) : (uint)0; elementData.FileName = playListElement.Attribute("event_file_name_id") != null && !string.IsNullOrEmpty(playListElement.Attribute("event_file_name_id").Value) ? playListElement.Attribute("event_file_name_id").Value : ""; elementData.Repeat = playListElement.Attribute("event_repeat") != null && !string.IsNullOrEmpty(playListElement.Attribute("event_repeat").Value) ? bool.Parse(playListElement.Attribute("event_repeat").Value) : false; elementData.Title = playListElement.Attribute("event_title") != null && !string.IsNullOrEmpty(playListElement.Attribute("event_title").Value) ? playListElement.Attribute("event_title").Value : ""; List <PlaylistElementSecondaryEventData> listSecData = new List <PlaylistElementSecondaryEventData>(); if (playListElement.Elements("Event").Count() > 0) { foreach (XElement secondaryElement in playListElement.Elements("Event")) { PlaylistElementSecondaryEventData secData = new PlaylistElementSecondaryEventData(); secData.Duration = secondaryElement.Attribute("sec_evt_duration") != null && !string.IsNullOrEmpty(secondaryElement.Attribute("sec_evt_duration").Value) ? (uint)int.Parse(secondaryElement.Attribute("sec_evt_duration").Value) : (uint)0; secData.ExtendedParam = secondaryElement.Attribute("sec_evt_ext_param") != null && !string.IsNullOrEmpty(secondaryElement.Attribute("sec_evt_ext_param").Value) ? secondaryElement.Attribute("sec_evt_ext_param").Value : ""; secData.Id = secondaryElement.Attribute("sec_evt_id") != null && !string.IsNullOrEmpty(secondaryElement.Attribute("sec_evt_id").Value) ? int.Parse(secondaryElement.Attribute("sec_evt_id").Value) : (int)0; secData.Param = secondaryElement.Attribute("sec_evt_ext_param") != null && !string.IsNullOrEmpty(secondaryElement.Attribute("sec_evt_ext_param").Value) ? secondaryElement.Attribute("sec_evt_ext_param").Value : ""; secData.TcOffsetType = secondaryElement.Attribute("sec_evt_tc_offset_type") != null && !string.IsNullOrEmpty(secondaryElement.Attribute("sec_evt_tc_offset_type").Value) ? (uint)int.Parse(secondaryElement.Attribute("sec_evt_tc_offset_type").Value) : (uint)0; secData.SecondaryEventType = secondaryElement.Attribute("sec_evt_type") != null && !string.IsNullOrEmpty(secondaryElement.Attribute("sec_evt_type").Value) ? secondaryElement.Attribute("sec_evt_type").Value : ""; listSecData.Add(secData); } } elementData.SecondaryEvents = listSecData.ToArray(); elementsData.Add(elementData); } data.Elements = elementsData.ToArray(); return(data); }
public PlaylistElement(PlaylistElementData Data) { this.Data = Data; switch (this.Data.ElementType) { case ElementType.Support: Support support = new Support(); support.Data = new SupportData(); support.Data.UIdSupport = this.Data.Uid; support.Data.Title = this.Data.Title; support.Data.FileName = this.Data.FileName; support.Data.TcStart = this.Data.TCIn; support.Data.Duration = 0; support.Data.FrameRate = FrameRate.PAL; break; } }