Ejemplo n.º 1
0
        static VmapAdBreak LoadAdBreak(XElement adBreakXml)
        {
            var result = new VmapAdBreak();

            result.BreakId    = (string)adBreakXml.Attribute("breakId");
            result.BreakType  = (string)adBreakXml.Attribute("breakType");
            result.TimeOffset = (string)adBreakXml.Attribute("timeOffset");
            var adSourceXml = adBreakXml.Element(ns + "AdSource");

            if (adSourceXml != null)
            {
                result.AdSource = LoadAdSource(adSourceXml);
            }
            var trackingEventsXml = adBreakXml.Element(ns + "TrackingEvents");

            if (trackingEventsXml != null)
            {
                foreach (var trackingEventXml in trackingEventsXml.Elements(ns + "Tracking"))
                {
                    result.TrackingEvents.Add(LoadTrackingEvent(trackingEventXml));
                }
            }
            var extensionsXml = adBreakXml.Element(ns + "Extensions");

            if (extensionsXml != null)
            {
                foreach (var extensionXml in extensionsXml.Elements(ns + "Extension"))
                {
                    result.Extensions.Add(LoadExtension(extensionXml));
                }
            }

            return(result);
        }
Ejemplo n.º 2
0
        static VmapAdBreak LoadAdBreak(XElement adBreakXml)
        {
            var result = new VmapAdBreak();

            result.BreakId = (string)adBreakXml.Attribute("breakId");
            result.BreakType = (string)adBreakXml.Attribute("breakType");
            result.TimeOffset = (string)adBreakXml.Attribute("timeOffset");
            var adSourceXml = adBreakXml.Element(ns + "AdSource");
            if (adSourceXml != null)
            {
                result.AdSource = LoadAdSource(adSourceXml);
            }
            var trackingEventsXml = adBreakXml.Element(ns + "TrackingEvents");
            if (trackingEventsXml != null)
            {
                foreach (var trackingEventXml in trackingEventsXml.Elements(ns + "Tracking"))
                {
                    result.TrackingEvents.Add(LoadTrackingEvent(trackingEventXml));
                }
            }
            var extensionsXml = adBreakXml.Element(ns + "Extensions");
            if (extensionsXml != null)
            {
                foreach (var extensionXml in extensionsXml.Elements(ns + "Extension"))
                {
                    result.Extensions.Add(LoadExtension(extensionXml));
                }
            }

            return result;
        }
        private void CreateAdvertisement(VmapAdBreak adBreak)
        {
            Advertisement ad = null;
            switch (adBreak.TimeOffset)
            {
                case "start":
                    ad = new PrerollAdvertisement();
                    break;
                case "end":
                    ad = new PostrollAdvertisement();
                    break;
                default:
                    var offset = FlexibleOffset.Parse(adBreak.TimeOffset);
                    if (offset != null)
                    {
                        var midroll = new MidrollAdvertisement();
                        if (!offset.IsAbsolute)
                        {
                            midroll.TimePercentage = offset.RelativeOffset;
                        }
                        else
                        {
                            midroll.Time = offset.AbsoluteOffset;
                        }
                        ad = midroll;
                    }
                    break;
            }

            if (ad != null)
            {
                ad.Source = GetAdSource(adBreak.AdSource);
                if (ad.Source != null)
                {
                    Advertisements.Add(ad);
                    adBreaks.Add(ad, adBreak);
                }
            }
        }