Exemplo n.º 1
0
        //IPlayItem IPlayItem.Clone()
        //{
        //    return (IPlayItem)this.Clone();
        //}

        //protected override PlaybillItem Clone()
        //{
        //    var result= new TimingPlaybillItem(this.PlaySource.Clone(),
        //        this.StartTime.Value, this.ScheduleMode == PlayScheduleMode.TimingBreak);
        //    result.Id = this.Id;
        //    return result;
        //}

        //public override IPlaybillItem Clone(PlayRange newRange)
        //{
        //    throw new NotImplementedException();
        //}

        public override IPlaybillItem Clone(PlayRange newRange)
        {
            var newSource = this.PlaySource.Clone(newRange);
            var result    = new TimingPlaybillItem(newSource, this.StartTime.Value, this.ScheduleMode == PlayScheduleMode.TimingBreak ? true: false);

            result.Id = Guid.NewGuid();
            return(result);
        }
Exemplo n.º 2
0
        internal void ChangeSource(IPlayItem playItem, IMediaSource newSource, PlayRange?newRange)
        {
            int index = _playItems.IndexOf(playItem);

            if (index < 0)
            {
                throw new ArgumentException();
            }

            IPlayItem newPlayItem = null;

            if (newRange != null && playItem.ScheduleMode != PlayScheduleMode.Auto)
            {
                if (newRange.Value.Duration > playItem.PlayRange.Duration)
                {
                    var newStopTime = playItem.StartTime.Add(newRange.Value.Duration);
                    if (this.HasTimingConflict(playItem.StartTime, newStopTime, playItem))
                    {
                        throw new InvalidOperationException();
                    }
                }
            }
            else
            {
            }

            newRange = newRange == null ? new PlayRange(TimeSpan.Zero, playItem.CalculatedPlayDuration) : newRange.Value;
            var newPlaySource = new PlaySource(newSource, newRange.Value, playItem.PlaybillItem.PlaySource.CGItems);

            switch (playItem.ScheduleMode)
            {
            case PlayScheduleMode.Auto:
                newPlayItem = new AutoPlayItem(AutoPlaybillItem.Auto(newPlaySource));
                break;

            case PlayScheduleMode.Timing:
                newPlayItem = (IPlayItem)TimingPlaybillItem.Timing(newPlaySource, playItem.StartTime);
                break;

            case PlayScheduleMode.TimingBreak:
                newPlayItem = (IPlayItem)TimingPlaybillItem.TimingBreak(newPlaySource, playItem.StartTime);
                break;
            }

            _playItems[index] = newPlayItem;
            this.IsDirty      = true;
        }
Exemplo n.º 3
0
        public void ChangeStartTime(IPlayItem playItem, DateTime newStartTime)
        {
            // TODO: 检查操作合法性。
            if (newStartTime == playItem.StartTime)
            {
                return;
            }


            if (playItem.ScheduleMode == PlayScheduleMode.Timing)
            {
                ChangeTimingStartTime(playItem, newStartTime);
            }
            else if (playItem.ScheduleMode == PlayScheduleMode.TimingBreak)
            {
                var newBreakItem = (TimingPlaybillItem)TimingPlaybillItem.TimingBreak(playItem.PlaybillItem.PlaySource, newStartTime);
                this.RemoveItem(playItem);             // remove a break item
                this.AddTimingBreakItem(newBreakItem); // add a new breakItem
            }
            else
            {
                throw new ArgumentException();
            }
        }
Exemplo n.º 4
0
        internal void ChangeStartTime(DateTime newStartTime)
        {
            if (_playItems[0].ScheduleMode != PlayScheduleMode.Timing)
            {
                throw new InvalidOperationException();
            }

            var newStopTime = newStartTime.Add(_playItems[0].PlaybillItem.PlayRange.Duration);

            var prevSegment = this.Previous;

            if (newStartTime < this.StartTime)
            {
                if (prevSegment != null)
                {
                    if (prevSegment.HasTimingConflict(newStartTime, newStopTime))
                    {
                        throw new InvalidOperationException("定时播或定时插播之间有时间冲突。");
                    }
                    for (int i = prevSegment._playItems.Count - 1; i >= 0; i--)
                    {
                        var item = prevSegment._playItems[i];
                        if (item.ScheduleMode == PlayScheduleMode.TimingBreak)
                        {
                            if (item.StartTime >= newStartTime)
                            {
                                this._playItems.Insert(1, item);
                                //AddNewTimingBreakItem(item);
                                prevSegment._playItems.Remove(item);
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                }
            }
            else //newStartTime > this.StartTime
            {
                if (this.HasTimingConflict(newStartTime, newStopTime, _playItems[0]))
                {
                    throw new InvalidOperationException("定时播或定时插播之间有时间冲突。");
                }

                for (int i = this._playItems.Count - 1; i >= 0; i--)
                {
                    var item = this._playItems[i];
                    if (item.ScheduleMode == PlayScheduleMode.TimingBreak)
                    {
                        if (item.StartTime < newStartTime)
                        {
                            if (prevSegment == null)
                            {
                                throw new InvalidOperationException();
                            }

                            prevSegment._playItems.Add(item);
                            //prevSegment.AddNewTimingBreakItem(item);
                            this._playItems.Remove(item);
                        }
                    }
                }
            }

            var playSource = _playItems[0].PlaybillItem.PlaySource;

            _playItems[0] = (TimingPlaybillItem)TimingPlaybillItem.Timing(playSource, newStartTime);

            if (prevSegment != null)
            {
                prevSegment.IsDirty = true;
            }
            this.IsDirty = true;
        }