Exemplo n.º 1
0
        public static IPlaybillItem ToPlaybillItem(this PlaybillItemEntity entity)
        {
            MediaSourceEntity sourceEntity = entity.MediaSource;
            IMediaSource      mediaSource  = null;

            if (sourceEntity == null)
            {
                mediaSource = new NullMediaSource(entity.MediaSourceTitle, TimeSpan.FromSeconds(entity.MediaSourceDuration.Value));
            }
            else
            {
                mediaSource = entity.MediaSource.ToMediaSource(entity); // FromEntity(entity, entity.MediaSource);
            }

            IPlaySource   playSource = Create(entity, mediaSource);
            IPlaybillItem result     = null;

            switch (entity.ScheduleMode)
            {
            case PlayScheduleMode.Auto:
                result = PlaybillItem.Auto(playSource);
                break;

            case PlayScheduleMode.Timing:
                result = PlaybillItem.Timing(playSource, entity.StartTime.Value);
                break;

            case PlayScheduleMode.TimingBreak:
                result = PlaybillItem.TimingBreak(playSource, entity.StartTime.Value);
                break;
            }
            result.Id = entity.Id;
            return(result);
        }
Exemplo n.º 2
0
        public static IMediaSource ToMediaSource(this MediaSourceEntity entity, PlaybillItemEntity billItemEntity)
        {
            IMediaSource    result     = null;
            MediaFileEntity fileEntity = entity as MediaFileEntity;

            if (fileEntity != null)
            {
                var fileSource = new FileMediaSource(fileEntity);
                fileSource.AudioGain = billItemEntity.AudioGain;
                result = fileSource;
            }
            else
            {
                ChannelInfo ci = entity as ChannelInfo;
                if (ci != null)
                {
                    var channelSource = new ChannelMediaSource(ci);
                    result = channelSource;
                }
                else
                {
                    throw new ArgumentException();
                }
            }
            return(result);
        }
Exemplo n.º 3
0
        public static PlaybillItemEntity ToEntity(PlaybillEntity billEntity, IPlaybillItem billItem, IMediaSource replaceAutoPadding)
        {
            var dtoItem = new PlaybillItemEntity();

            dtoItem.Id = billItem.Id;

            dtoItem.Playbill = billEntity;

            dtoItem.StartTime      = billItem.StartTime;
            dtoItem.MarkerIn       = billItem.PlayRange.StartPosition.TotalSeconds;
            dtoItem.ScheduleMode   = billItem.ScheduleMode;
            dtoItem.MarkerDuration = billItem.PlayRange.Duration.TotalSeconds;
            //_dtoItem.SegmentId = this.SegmentId;

            if (billItem.MediaSource.Category != MediaSourceCategory.Null)
            {
                dtoItem.MediaSourceId = billItem.MediaSource.Id;
            }
            else
            {
                dtoItem.MediaSourceTitle    = billItem.MediaSource.Title;
                dtoItem.MediaSourceDuration = billItem.MediaSource.Duration.Value.TotalSeconds;
            }

            var autoBillItem = billItem as AutoPlaybillItem;

            if (autoBillItem != null)
            {
                if (autoBillItem.IsAutoPadding && replaceAutoPadding != null)
                {
                    // TODO: 替换自动垫片。

                    dtoItem.MediaSourceId = replaceAutoPadding.Id;

                    //dtoItem.IsAutoPadding = autoBillItem.IsAutoPadding;
                }
            }


            var fileMediaSource = billItem.MediaSource as IFileMediaSource;

            if (fileMediaSource != null)
            {
                dtoItem.AudioGain = fileMediaSource.AudioGain;
            }

            if (billItem.CGItems != null)
            {
                dtoItem.CGContents = CGItemCollection.ToXml(billItem.CGItems);
            }

            return(dtoItem);
        }
Exemplo n.º 4
0
        private static IPlaySource Create(PlaybillItemEntity entity, IMediaSource mediaSource)
        {
            var range = new PlayRange(TimeSpan.FromSeconds(entity.MarkerIn), TimeSpan.FromSeconds(entity.MarkerDuration));

            CGItemCollection cgItems = null;


            if (entity.CGContents != null)
            {
                cgItems = CGItemCollection.FromXml(entity.CGContents);
            }

            if (cgItems == null)
            {
                return(new PlaySource(mediaSource, range));
            }
            else
            {
                return(new PlaySource(mediaSource, range, cgItems));
            }
        }