public IPlayer GetPlayer(MediaItem mediaItem)
        {
            string mimeType;
            string title;

            if (!mediaItem.GetPlayData(out mimeType, out title))
            {
                return(null);
            }
            if (mimeType != "video/livetv")
            {
                return(null);
            }
            IResourceLocator locator = mediaItem.GetResourceLocator();
            LiveTvPlayer     player  = new LiveTvPlayer();

            try
            {
                player.SetMediaItem(locator, title);
            }
            catch (Exception e)
            {
                ServiceRegistration.Get <ILogger>().Warn("LiveTvPlayer: Error playing media item '{0}'", e, locator);
                player.Dispose();
                return(null);
            }
            return(player);
        }
        protected override void Update()
        {
            // Don't update the current channel and program information if we are in zap osd.
            if (!_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;
                    if (context != null)
                    {
                        ChannelName = context.Channel.Name;
                        CurrentProgram.SetProgram(context.Program);
                        if (context.Program != null)
                        {
                            IProgram 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.SetProgram(nextPrograms[0]);
                            }
                        }
                    }
                }
            }
        }
 public IPlayer GetPlayer(MediaItem mediaItem)
 {
     string mimeType;
       string title;
       if (!mediaItem.GetPlayData(out mimeType, out title))
     return null;
       if (mimeType != "video/livetv")
     return null;
       IResourceLocator locator = mediaItem.GetResourceLocator();
       LiveTvPlayer player = new LiveTvPlayer();
       try
       {
     player.SetMediaItem(locator, title);
       }
       catch (Exception e)
       {
     ServiceRegistration.Get<ILogger>().Warn("LiveTvPlayer: Error playing media item '{0}'", e, locator);
     player.Dispose();
     return null;
       }
       return player;
 }