예제 #1
0
        private static TimedTextAnimation BuildCaptionAnimationElement(TimedTextElementBase element)
        {
            var propertyName = element.Attributes
                               .Where(i => TimedTextStyleParser.IsValidAnimationPropertyName(i.LocalName))
                               .Select(i => i.LocalName)
                               .FirstOrDefault();

            return(!propertyName.IsNullOrWhiteSpace()
                    ? new TimedTextAnimation
            {
                CaptionElementType = TimedTextElementType.Animation,
                PropertyName = propertyName,
                Style = TimedTextStyleParser.MapStyle(element, null)
            }
                    : null);
        }
예제 #2
0
        private static CaptionRegion MapToCaptionRegion(RegionElement regionElement)
        {
            var endTime = regionElement.End.TotalSeconds >= TimeSpan.MaxValue.TotalSeconds
                            ? TimeSpan.MaxValue
                            : TimeSpan.FromSeconds(regionElement.End.TotalSeconds);

            var captionRegion = new CaptionRegion
            {
                Id           = regionElement.Id,
                Begin        = TimeSpan.FromSeconds(regionElement.Begin.TotalSeconds),
                End          = endTime,
                Style        = TimedTextStyleParser.MapStyle(regionElement, null),
                TunneledData = regionElement.Root.Images.ToDictionary(ie => ie.Key, ie => new TunneledData()
                {
                    Data = ie.Value.Data, Encoding = ie.Value.Encoding, MimeType = ie.Value.ImageType
                })
            };



            foreach (TimedTextElementBase element in regionElement.Children)
            {
                TimedTextElement child = BuildTimedTextElements(element, null);
                if (child != null && child.CaptionElementType == TimedTextElementType.Animation)
                {
#if HACK_XAMLTYPEINFO
                    var children = captionRegion.Animations as MediaMarkerCollection <TimedTextAnimation>;
#else
                    var children = captionRegion.Animations;
#endif
                    children.Add(child as TimedTextAnimation);
                }
            }

            return(captionRegion);
        }