Beispiel #1
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;
        }
Beispiel #2
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();
            }
        }