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); }
//public PlayItemEntity ToEntity(PlaybillEntity billEntity, IPlayItem playItem) //{ // var dtoItem = new PlayItemEntity(); // dtoItem.Id = playItem.Id; // dtoItem.StartTime = playItem.StartTime; // dtoItem.PlayDuration = playItem.CalculatedPlayDuration.TotalSeconds; // dtoItem.MarkerIn = playItem.PlayRange.StartPosition.TotalSeconds; // dtoItem.MarkerDuration = playItem.PlayRange.Duration.TotalSeconds; // dtoItem.PlaybillItem = ToEntity(billEntity, playItem.PlaybillItem); // return dtoItem; //} //public PlaybillItemEntity ToEntity(PlaybillEntity billEntity, IPlaybillItem billItem) //{ // 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; // 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) // { // 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; //} public static Playbill Load(Guid id, IList <IPlayItem> playItemList) { PlaybillEntity billEntity = PlayoutRepository.GetPlaybill(id); // GetEntity(id); Playbill playbill = null; Dictionary <Guid, IPlaybillItem> playbillItemDict = new Dictionary <Guid, IPlaybillItem>(); if (billEntity != null) { playbill = new Playbill(billEntity); for (int i = 0; i < billEntity.PlayItems.Count; i++) { PlayItemEntity playItemEntity = billEntity.PlayItems[i]; IPlaybillItem playbillItem = null; if (!playbillItemDict.ContainsKey(playItemEntity.PlaybillItemId)) { playbillItem = playItemEntity.PlaybillItem.ToPlaybillItem(); // FromEntity(playItemEntity.PlaybillItem); playbillItemDict.Add(playItemEntity.PlaybillItemId, playbillItem); } else { playbillItem = playbillItemDict[playItemEntity.PlaybillItemId]; } IPlayItem playItem = playItemEntity.ToPlayItem(playbillItem); // FromEntity(playItemEntity,playbillItem); playItemList.Add(playItem); } } return(playbill); }
public override IPlaybillItem Merge(IPlaybillItem playbillItem) { if (!CanMerge(playbillItem)) { throw new InvalidOperationException(); } return(new AutoPlaybillItem(this.PlaySource.Merge(playbillItem.PlaySource))); }
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); }
public PlaybillItemEntity(IPlaybillItem billItem, Func <IMediaSource, MediaSourceEntity> converter) { this.Id = billItem.Id; //this.Playbill = billEntity; this.StartTime = billItem.StartTime; this.MarkerIn = billItem.PlayRange.StartPosition.TotalSeconds; this.ScheduleMode = billItem.ScheduleMode; this.MarkerDuration = billItem.PlayRange.Duration.TotalSeconds; if (billItem.MediaSource.Category != MediaSourceCategory.Null) { this.MediaSourceId = billItem.MediaSource.Id; if (converter != null) { this.MediaSource = converter(billItem.MediaSource); } } else { this.MediaSourceTitle = billItem.MediaSource.Title; this.MediaSourceDuration = billItem.MediaSource.Duration.Value.TotalSeconds; } var autoBillItem = billItem as AutoPlaybillItem; if (autoBillItem != null) { this.IsAutoPadding = autoBillItem.IsAutoPadding; } var fileMediaSource = billItem.MediaSource as IFileMediaSource; if (fileMediaSource != null) { this.AudioGain = fileMediaSource.AudioGain; } if (billItem.CGItems != null) { this.CGContents = CGItemCollection.ToXml(billItem.CGItems); } }
public static IPlayItem ToPlayItem(this PlayItemEntity entity, IPlaybillItem playbillItem) { if (playbillItem.ScheduleMode == PlayScheduleMode.Auto) { var autoPlayItem = new AutoPlayItem(playbillItem); autoPlayItem.StartTime = entity.StartTime; autoPlayItem.CalculatedPlayDuration = TimeSpan.FromSeconds(entity.PlayDuration); autoPlayItem.PlayRange = new PlayRange(TimeSpan.FromSeconds(entity.MarkerIn), TimeSpan.FromSeconds(entity.MarkerDuration)); //autoPlayItem.PlaybillItem = playbillItem; autoPlayItem.Id = entity.Id; return(autoPlayItem); } else { return((TimingPlaybillItem)playbillItem); } //throw new NotImplementedException(); }
public static IPlayItem ToPlayItem(this PlayItemEntity entity) { IPlaybillItem playbillItem = entity.PlaybillItem.ToPlaybillItem(); // FromEntity(entity.PlaybillItem); if (playbillItem.ScheduleMode == PlayScheduleMode.Auto) { var autoPlayItem = new AutoPlayItem(playbillItem); autoPlayItem.StartTime = entity.StartTime; autoPlayItem.CalculatedPlayDuration = TimeSpan.FromSeconds(entity.PlayDuration); autoPlayItem.PlayRange = new PlayRange(TimeSpan.FromSeconds(entity.MarkerIn), TimeSpan.FromSeconds(entity.MarkerDuration)); autoPlayItem.Id = entity.Id; return(autoPlayItem); } else { return((TimingPlaybillItem)playbillItem); } }
public virtual IPlaybillItem Merge(IPlaybillItem playbillItem) { throw new NotSupportedException(); }
public override bool CanMerge(IPlaybillItem playbillItem) { return(this.PlaySource.CanMerge(playbillItem.PlaySource)); }
// 用于创建顺播片断。 private AutoPlayItem(IPlaybillItem billItem, PlayRange playRange) : this(billItem) { this.PlayRange = playRange; }
public AutoPlayItem(IPlaybillItem billItem) { this.Id = Guid.NewGuid(); this.PlaybillItem = billItem; }