Пример #1
0
        protected void UpdateForChannel(IChannel channel)
        {
            ChannelName = channel.Name;
            IProgram currentProgram;

            if (_tvHandler.ProgramInfo.GetCurrentProgram(channel, out currentProgram))
            {
                CurrentProgram.SetProgram(currentProgram);
                double progress = (DateTime.Now - currentProgram.StartTime).TotalSeconds /
                                  (currentProgram.EndTime - currentProgram.StartTime).TotalSeconds * 100;
                _programProgressProperty.SetValue(progress);
            }
            else
            {
                CurrentProgram.SetProgram(null);
                _programProgressProperty.SetValue(100d);
            }

            IProgram nextProgram;

            if (_tvHandler.ProgramInfo.GetNextProgram(channel, out nextProgram))
            {
                NextProgram.SetProgram(nextProgram);
            }
        }
Пример #2
0
        protected async override void Update()
        {
            // Don't update the current channel and program information if we are in zap osd.
            if (_tvHandler == null || (_zapTimer != null && _zapTimer.IsEventPending))
            {
                return;
            }

            // Update current programs for all channels of current group (visible inside MiniGuide).
            await UpdateAllCurrentPrograms();

            _zapChannelIndex = ChannelContext.Instance.Channels.CurrentIndex;

            if (_tvHandler.NumberOfActiveSlots < 1)
            {
                PiPAvailable = false;
                PiPEnabled   = false;
                return;
            }

            PiPAvailable = true;

            // get the current channel and program out of the LiveTvMediaItems' TimeshiftContexes
            IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>();
            IPlayerContext        playerContext        = playerContextManager.GetPlayerContext(PlayerChoice.PrimaryPlayer);

            if (playerContext != null)
            {
                ILivePlayer player = playerContext.CurrentPlayer as ILivePlayer;
                if (player != null)
                {
                    LiveTvMediaItem   item           = player.CurrentItem;
                    ITimeshiftContext context        = item == null ? null : item.TimeshiftContexes.LastOrDefault();
                    IProgram          currentProgram = null;
                    IProgram          nextProgram    = null;
                    IChannel          channel        = null;
                    if (context != null && context.Channel != null)
                    {
                        channel         = context.Channel;
                        ChannelName     = channel.Name;
                        ChannelLogoType = channel.GetFanArtMediaType();
                        if (_tvHandler.ProgramInfo != null)
                        {
                            var result = await _tvHandler.ProgramInfo.GetNowNextProgramAsync(channel);

                            if (result.Success)
                            {
                                currentProgram = result.Result[0];
                                nextProgram    = result.Result[1];
                                double progress = currentProgram == null ? 100d : (DateTime.Now - currentProgram.StartTime).TotalSeconds /
                                                  (currentProgram.EndTime - currentProgram.StartTime).TotalSeconds * 100;
                                _programProgressProperty.SetValue(progress);
                            }
                        }
                    }
                    CurrentProgram.SetProgram(currentProgram, channel);
                    NextProgram.SetProgram(nextProgram, channel);
                }
            }
        }
Пример #3
0
        protected override void Update()
        {
            // Don't update the current channel and program information if we are in zap osd.
            if (_tvHandler == null || !_active || _zapTimer != null)
            {
                return;
            }

            if (_tvHandler.NumberOfActiveSlots < 1)
            {
                PiPAvailable = false;
                PiPEnabled   = false;
                return;
            }

            PiPAvailable = true;

            // get the current channel and program out of the LiveTvMediaItems' TimeshiftContexes
            IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>();
            IPlayerContext        playerContext        = playerContextManager.GetPlayerContext(PlayerChoice.PrimaryPlayer);

            if (playerContext != null)
            {
                LiveTvMediaItem liveTvMediaItem = playerContext.CurrentMediaItem as LiveTvMediaItem;
                LiveTvPlayer    player          = playerContext.CurrentPlayer as LiveTvPlayer;
                if (liveTvMediaItem != null && player != null)
                {
                    ITimeshiftContext context        = player.CurrentTimeshiftContext;
                    IProgram          currentProgram = null;
                    IProgram          nextProgram    = null;
                    if (context != null)
                    {
                        ChannelName    = context.Channel.Name;
                        currentProgram = context.Program;
                        if (currentProgram != null)
                        {
                            currentProgram = context.Program;
                            double progress = (DateTime.Now - currentProgram.StartTime).TotalSeconds /
                                              (currentProgram.EndTime - currentProgram.StartTime).TotalSeconds * 100;
                            _programProgressProperty.SetValue(progress);

                            IList <IProgram> nextPrograms;
                            DateTime         nextTime = currentProgram.EndTime.Add(TimeSpan.FromSeconds(10));
                            if (_tvHandler.ProgramInfo.GetPrograms(context.Channel, nextTime, nextTime, out nextPrograms))
                            {
                                nextProgram = nextPrograms[0];
                            }
                        }
                    }
                    CurrentProgram.SetProgram(currentProgram);
                    NextProgram.SetProgram(nextProgram);
                }
            }
        }
Пример #4
0
        protected override void Update()
        {
            // Don't update the current channel and program information if we are in zap osd.
            if (_tvHandler == null || (_zapTimer != null && _zapTimer.IsEventPending))
            {
                return;
            }

            // Update current programs for all channels of current group (visible inside MiniGuide).
            UpdateAllCurrentPrograms();

            _zapChannelIndex = ChannelContext.Instance.Channels.CurrentIndex;

            if (_tvHandler.NumberOfActiveSlots < 1)
            {
                PiPAvailable = false;
                PiPEnabled   = false;
                return;
            }

            PiPAvailable = true;

            // get the current channel and program out of the LiveTvMediaItems' TimeshiftContexes
            IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>();
            IPlayerContext        playerContext        = playerContextManager.GetPlayerContext(PlayerChoice.PrimaryPlayer);

            if (playerContext != null)
            {
                LiveTvPlayer player = playerContext.CurrentPlayer as LiveTvPlayer;
                if (player != null)
                {
                    ITimeshiftContext context        = player.TimeshiftContexes.LastOrDefault();
                    IProgram          currentProgram = null;
                    IProgram          nextProgram    = null;
                    if (context != null && context.Channel != null)
                    {
                        ChannelName = context.Channel.Name;
                        if (_tvHandler.ProgramInfo != null && _tvHandler.ProgramInfo.GetNowNextProgram(context.Channel, out currentProgram, out nextProgram) && currentProgram != null)
                        {
                            double progress = (DateTime.Now - currentProgram.StartTime).TotalSeconds /
                                              (currentProgram.EndTime - currentProgram.StartTime).TotalSeconds * 100;
                            _programProgressProperty.SetValue(progress);
                        }
                    }
                    CurrentProgram.SetProgram(currentProgram);
                    NextProgram.SetProgram(nextProgram);
                }
            }
        }
        public void UpdateSchedule(object sender, SelectionChangedEventArgs e)
        {
            var selectedItem = e.FirstAddedItem as ListItem;

            if (selectedItem == null)
            {
                return;
            }
            ISchedule schedule = (ISchedule)selectedItem.AdditionalProperties["SCHEDULE"];

            UpdateScheduleDetails(schedule).Wait();
            if (selectedItem.AdditionalProperties.ContainsKey("PROGRAM"))
            {
                IProgram program = (IProgram)selectedItem.AdditionalProperties["PROGRAM"];
                CurrentProgram.SetProgram(program);
            }
            else
            {
                CurrentProgram.SetProgram(null);
            }
        }
 protected virtual void UpdateProgramStatus(IProgram program)
 {
     CurrentProgram.SetProgram(program);
 }
Пример #7
0
 private void UpdateSingleProgramInfo(IProgram program)
 {
     CurrentProgram.SetProgram(program);
 }