Esempio n. 1
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);
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        internal static MediaSourceBase Create(MediaSourceEntity entity)
        {
            var file = entity as MediaFileEntity;

            if (file != null)
            {
                return(new FileMediaSource(file));
            }

            //new ChannelMediaSource()
            throw new ArgumentException();
        }
Esempio n. 4
0
        public static MediaSourceEntity ToEntity(MediaItem mediaItem)
        {
            MediaSourceEntity entity = mediaItem.Source.GetSourceEntity(); //.Entity;

            var rangeMarkable = entity as IRangeMarkable;

            if (rangeMarkable != null)
            {
                rangeMarkable.MarkerIn       = mediaItem.PlayRange.StartPosition.TotalSeconds;
                rangeMarkable.MarkerDuration = mediaItem.PlayRange.Duration.TotalSeconds;
            }

            return(entity);
        }
Esempio n. 5
0
        protected MediaSourceBase(MediaSourceCategory category, MediaSourceEntity entity)
            : this(category)
        {
            //this.Category = category;

            this.Title = entity.Title;
            var fileEntity = entity as MediaFileEntity;
            if (fileEntity != null)
            {
                this.Duration = TimeSpan.FromSeconds(fileEntity.Duration);
            }

            this.Entity = entity;
            this.Id     = entity.Id;
        }
Esempio n. 6
0
        public static MediaItem FromEntity(MediaSourceEntity entity)
        {
            MediaSourceBase source = MediaSourceBase.Create(entity);

            var       fileEntity = entity as MediaFileEntity;
            PlayRange playRange;

            if (fileEntity != null)
            {
                playRange = new PlayRange(TimeSpan.FromSeconds(fileEntity.MarkerIn),
                                          TimeSpan.FromSeconds(fileEntity.MarkerDuration));
            }
            else
            {
                playRange = new PlayRange(PlayoutConfiguration.Current.DefaultDuration);
            }

            return(new MediaItem(source, playRange));
        }
Esempio n. 7
0
        public static IMediaSource ToMediaSource(this MediaSourceEntity entity)
        {
            MediaFileEntity fileEntity = entity as MediaFileEntity;

            if (fileEntity != null)
            {
                return(new FileMediaSource(fileEntity));
            }
            else
            {
                ChannelInfo ci = entity as ChannelInfo;
                if (ci != null)
                {
                    return(new ChannelMediaSource(ci));
                }
                else
                {
                    throw new ArgumentException();
                }
            }
        }