示例#1
0
        private void UpdateExistingMediaItem(MediaItem timeshiftMediaItem)
        {
            IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>();

            for (int index = 0; index < playerContextManager.NumActivePlayerContexts; index++)
            {
                IPlayerContext playerContext = playerContextManager.GetPlayerContext(index);
                if (playerContext == null)
                {
                    continue;
                }
                LiveTvMediaItem liveTvMediaItem    = playerContext.CurrentMediaItem as LiveTvMediaItem;
                LiveTvMediaItem newLiveTvMediaItem = timeshiftMediaItem as LiveTvMediaItem;
                // Check if this is "our" media item to update.
                if (liveTvMediaItem == null || newLiveTvMediaItem == null || !IsSameSlot(liveTvMediaItem, newLiveTvMediaItem))
                {
                    continue;
                }

                if (!IsSameLiveTvItem(liveTvMediaItem, newLiveTvMediaItem))
                {
                    // Switch MediaItem in current slot, the LiveTvPlayer implements IReusablePlayer and will change its source without need to change full player.
                    playerContext.DoPlay(newLiveTvMediaItem);
                    // Copy old channel history into new item
                    liveTvMediaItem.TimeshiftContexes.ToList().ForEach(tc => newLiveTvMediaItem.TimeshiftContexes.Add(tc));
                    // Use new MediaItem, so new context will be added to new instance.
                    liveTvMediaItem = newLiveTvMediaItem;
                }
                // Add new timeshift context
                AddOrUpdateTimeshiftContext(liveTvMediaItem, newLiveTvMediaItem.AdditionalProperties[LiveTvMediaItem.CHANNEL] as IChannel);
            }
        }
示例#2
0
        private void UpdateExistingMediaItem(MediaItem timeshiftMediaItem)
        {
            IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>();

            for (int index = 0; index < playerContextManager.NumActivePlayerContexts; index++)
            {
                IPlayerContext playerContext = playerContextManager.GetPlayerContext(index);
                if (playerContext != null)
                {
                    LiveTvMediaItem liveTvMediaItem    = playerContext.CurrentMediaItem as LiveTvMediaItem;
                    LiveTvMediaItem newLiveTvMediaItem = timeshiftMediaItem as LiveTvMediaItem;
                    if (liveTvMediaItem != null && newLiveTvMediaItem != null)
                    {
                        // check if this is "our" media item to update.
                        if ((int)liveTvMediaItem.AdditionalProperties[LiveTvMediaItem.SLOT_INDEX] == (int)newLiveTvMediaItem.AdditionalProperties[LiveTvMediaItem.SLOT_INDEX])
                        {
                            if (liveTvMediaItem.Aspects[ProviderResourceAspect.ASPECT_ID].GetAttributeValue(ProviderResourceAspect.ATTR_RESOURCE_ACCESSOR_PATH).ToString() !=
                                newLiveTvMediaItem.Aspects[ProviderResourceAspect.ASPECT_ID].GetAttributeValue(ProviderResourceAspect.ATTR_RESOURCE_ACCESSOR_PATH).ToString())
                            {
                                //switch MediaItem in current slot
                                playerContext.DoPlay(newLiveTvMediaItem);
                                //clear former timeshift contexes (card change cause loss of buffer in rtsp mode).
                                liveTvMediaItem.TimeshiftContexes.Clear();
                            }
                            // add new timeshift context
                            AddTimeshiftContext(liveTvMediaItem, newLiveTvMediaItem.AdditionalProperties[LiveTvMediaItem.CHANNEL] as IChannel);
                        }
                    }
                }
            }
        }
 protected void Update()
 {
   IWorkflowManager workflowManager = ServiceRegistration.Get<IWorkflowManager>();
   IPlayerContextManager playerContextManager = ServiceRegistration.Get<IPlayerContextManager>();
   IPlayerContext pc = playerContextManager.GetPlayerContext(PlayerChoice.CurrentPlayer);
   bool visible = pc != null;
   string displayTitleRes = null;
   if (pc != null)
     switch (pc.AVType)
     {
       case AVType.Audio:
         displayTitleRes = Consts.RES_SHOW_AUDIO_PLAYLIST;
         break;
       case AVType.Video:
         displayTitleRes = pc.IsPrimaryPlayerContext ? Consts.RES_SHOW_VIDEO_IMAGE_PLAYLIST : Consts.RES_SHOW_PIP_PLAYLIST;
         break;
       default:
         // Unknown player context type
         visible = false;
         break;
     }
   visible = visible && !workflowManager.IsStateContainedInNavigationStack(Consts.WF_STATE_ID_SHOW_PLAYLIST);
   lock (_syncObj)
   {
     if (visible == _isVisible && displayTitleRes == _displayTitleResource)
       return;
     _isVisible = visible;
     _displayTitleResource = displayTitleRes;
   }
   FireStateChanged();
 }
示例#4
0
        protected void UpdatePlaylist()
        {
            IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>();
            IPlayerContext        pc       = playerContextManager.GetPlayerContext(PlayerChoice.CurrentPlayer);
            IPlaylist             playlist = pc == null ? null : pc.Playlist;

            UpdatePlaylistHeader(pc == null ? null : (AVType?)pc.AVType, pc == null ? true : pc.IsPrimaryPlayerContext);
            lock (_syncObj)
            {
                // TODO: If playlist objects differ, leave state EditPlaylist?
                _playlist = playlist;
                _items.Clear();
                if (playlist != null)
                {
                    IList <MediaItem> items = playlist.ItemList;
                    for (int i = 0; i < items.Count; i++)
                    {
                        MediaItem         mediaItem = items[i];
                        PlayableMediaItem item      = PlayableMediaItem.CreateItem(mediaItem);

                        item.SetLabel(Consts.KEY_NUMBERSTR, (i + 1) + ".");
                        item.AdditionalProperties[Consts.KEY_INDEX] = i;

                        item.AdditionalProperties[Consts.KEY_IS_DOWN_BUTTON_FOCUSED] = i == _focusedDownButton;
                        item.AdditionalProperties[Consts.KEY_IS_UP_BUTTON_FOCUSED]   = i == _focusedUpButton;
                        _items.Add(item);
                    }
                }
                _focusedDownButton  = -1;
                _focusedUpButton    = -1;
                IsPlaylistEmpty     = _items.Count == 0;
                NumPlaylistItemsStr = Utils.BuildNumItemsStr(_items.Count, null);
            }
            _items.FireChange();
        }
        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);
                }
            }
        }
        public virtual void ShowZoomModeDialog()
        {
            IPlayerContextManager pcm = ServiceRegistration.Get <IPlayerContextManager>();
            IPlayerContext        pc  = pcm.GetPlayerContext(PlayerManagerConsts.PRIMARY_SLOT);

            PlayerConfigurationDialogModel.OpenChooseGeometryDialog(pc);
        }
 private void OnMessageReceived(AsynchronousMessageQueue queue, SystemMessage message)
 {
     if (message.ChannelName == SystemMessaging.CHANNEL)
     {
         SystemMessaging.MessageType messageType = (SystemMessaging.MessageType)message.MessageType;
         switch (messageType)
         {
         case SystemMessaging.MessageType.SystemStateChanged:
             SystemState newState = (SystemState)message.MessageData[SystemMessaging.NEW_STATE];
             if (newState == SystemState.Resuming)
             {
                 // Signal the event, callback is executed after timeout, see OnResume
                 _resumeEvent.EnqueueEvent(this, EventArgs.Empty);
             }
             if (newState == SystemState.Suspending)
             {
                 ServiceRegistration.Get <ILogger>().Info("SlimTvClientModel: System suspending, stopping all SlimTV players");
                 IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>();
                 for (int index = 0; index < playerContextManager.NumActivePlayerContexts; index++)
                 {
                     IPlayerContext playerContext = playerContextManager.GetPlayerContext(index);
                     if (playerContext != null && playerContext.CurrentMediaItem is LiveTvMediaItem)
                     {
                         playerContext.Stop();
                         _tvWasActive = true;
                     }
                 }
             }
             break;
         }
     }
 }
示例#8
0
        protected void UpdatePlaylist()
        {
            IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>();
            IPlayerContext        pc       = playerContextManager.GetPlayerContext(PlayerChoice.CurrentPlayer);
            IPlaylist             playlist = pc == null ? null : pc.Playlist;

            UpdatePlaylistHeader(pc == null ? null : (AVType?)pc.AVType, pc == null ? true : pc.IsPrimaryPlayerContext);
            lock (_syncObj)
            {
                _playlist = playlist;
                _playlistItems.Clear();
                if (playlist != null)
                {
                    int ct             = 0;
                    int currentItemIdx = playlist.ItemListIndex;
                    foreach (MediaItem mediaItem in playlist.ItemList)
                    {
                        int idx = ct++;
                        PlayableMediaItem item = PlayableMediaItem.CreateItem(mediaItem);

                        item.SetLabel(Consts.KEY_NUMBERSTR, (idx + 1) + ".");
                        item.AdditionalProperties[Consts.KEY_INDEX]           = idx;
                        item.AdditionalProperties[Consts.KEY_IS_CURRENT_ITEM] = currentItemIdx == idx;
                        _playlistItems.Add(item);
                    }
                }
                IsPlaylistEmpty     = _playlistItems.Count == 0;
                NumPlaylistItemsStr = Utils.BuildNumItemsStr(_playlistItems.Count, null);
            }
            _playlistItems.FireChange();
        }
示例#9
0
        private double[] OnNewVUMeter()
        {
            double[] dbLevel = new double[] { -200.0, -200.0 };

            IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>(false);

            if (playerContextManager == null)
            {
                return(dbLevel);
            }

            IPlayerContext playerContext = playerContextManager.GetPlayerContext(PlayerChoice.PrimaryPlayer);

            if (playerContext == null)
            {
                return(dbLevel);
            }

            IAudioPlayerAnalyze player = (playerContext.CurrentPlayer as IAudioPlayerAnalyze);

            if (player == null)
            {
                return(dbLevel);
            }

            double dbLevelL;
            double dbLevelR;

            if (player.GetChannelLevel(out dbLevelL, out dbLevelR))
            {
                dbLevel[0] = dbLevelL;
                dbLevel[1] = dbLevelR;
            }
            return(dbLevel);
        }
示例#10
0
        public bool CanEnterState(NavigationContext oldContext, NavigationContext newContext)
        {
            IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>();
            IPlayerContext        pc = playerContextManager.GetPlayerContext(PlayerChoice.CurrentPlayer);

            return(pc != null && (pc.AVType == AVType.Audio || pc.AVType == AVType.Video));
        }
示例#11
0
        protected void Update()
        {
            IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>();
            IWorkflowManager      workflowManager      = ServiceRegistration.Get <IWorkflowManager>();
            IPlayerContext        pcPrimary            = playerContextManager.GetPlayerContext(PlayerManagerConsts.PRIMARY_SLOT);
            IPlayer      primaryPlayer = pcPrimary == null ? null : pcPrimary.CurrentPlayer;
            IImagePlayer pp            = primaryPlayer as IImagePlayer;
            IVideoPlayer vp            = primaryPlayer as IVideoPlayer;
            IAudioPlayer ap            = primaryPlayer as IAudioPlayer;
            bool         visible       = (pp != null || vp != null || ap != null) &&
                                         !workflowManager.IsStateContainedInNavigationStack(pcPrimary.FullscreenContentWorkflowStateId);
            IResourceString displayTitleRes;

            if (ap != null)
            {
                displayTitleRes = LocalizationHelper.CreateResourceString(Consts.RES_AUDIO_VISUALIZATION);
            }
            else if (vp != null)
            {
                displayTitleRes = LocalizationHelper.CreateStaticString(
                    LocalizationHelper.CreateResourceString(Consts.RES_FULLSCREEN_VIDEO).Evaluate(vp.Name));
            }
            else
            {
                displayTitleRes = LocalizationHelper.CreateResourceString(Consts.RES_FULLSCREEN_IMAGE);
            }
            lock (_syncObj)
            {
                _isVisible            = visible;
                _displayTitleResource = displayTitleRes;
            }
            FireStateChanged();
        }
        private async Task <bool> InitActionsList()
        {
            IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>();
            IPlayerContext        playerContext        = playerContextManager.GetPlayerContext(PlayerChoice.PrimaryPlayer);

            if (playerContext == null)
            {
                return(false);
            }
            LiveTvMediaItem liveTvMediaItem = playerContext.CurrentMediaItem as LiveTvMediaItem;
            ILivePlayer     player          = playerContext.CurrentPlayer as ILivePlayer;

            if (liveTvMediaItem == null || player == null)
            {
                return(false);
            }

            ITimeshiftContext context = liveTvMediaItem.TimeshiftContexes.LastOrDefault();

            if (context == null || context.Channel == null)
            {
                return(false);
            }

            ILocalization localization = ServiceRegistration.Get <ILocalization>();
            var           result       = await _tvHandler.ProgramInfo.GetNowNextProgramAsync(context.Channel);

            return(await InitActionsList(result.Success?result.Result[0] : null, context.Channel));
        }
示例#13
0
        private void UpdateExistingMediaItem(MediaItem timeshiftMediaItem)
        {
            IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>();

            for (int index = 0; index < playerContextManager.NumActivePlayerContexts; index++)
            {
                IPlayerContext playerContext = playerContextManager.GetPlayerContext(index);
                if (playerContext == null)
                {
                    continue;
                }
                LiveTvMediaItem liveTvMediaItem    = playerContext.CurrentMediaItem as LiveTvMediaItem;
                LiveTvMediaItem newLiveTvMediaItem = timeshiftMediaItem as LiveTvMediaItem;
                // Check if this is "our" media item to update.
                if (liveTvMediaItem == null || newLiveTvMediaItem == null || !IsSameSlot(liveTvMediaItem, newLiveTvMediaItem))
                {
                    continue;
                }

                if (!IsSameLiveTvItem(liveTvMediaItem, newLiveTvMediaItem))
                {
                    // Switch MediaItem in current slot
                    playerContext.DoPlay(newLiveTvMediaItem);
                    // Clear former timeshift contexes (card change cause loss of buffer in rtsp mode).
                    liveTvMediaItem.TimeshiftContexes.Clear();
                }
                // Add new timeshift context
                AddTimeshiftContext(liveTvMediaItem, newLiveTvMediaItem.AdditionalProperties[LiveTvMediaItem.CHANNEL] as IChannel);
            }
        }
示例#14
0
        private bool InitActionsList()
        {
            _dialogActionsList.Clear();
            DialogHeader = "[SlimTvClient.RecordActions]";
            IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>();
            IPlayerContext        playerContext        = playerContextManager.GetPlayerContext(PlayerChoice.PrimaryPlayer);

            if (playerContext == null)
            {
                return(false);
            }
            LiveTvMediaItem liveTvMediaItem = playerContext.CurrentMediaItem as LiveTvMediaItem;
            LiveTvPlayer    player          = playerContext.CurrentPlayer as LiveTvPlayer;

            if (liveTvMediaItem == null || player == null)
            {
                return(false);
            }

            ITimeshiftContext context = player.TimeshiftContexes.LastOrDefault();

            if (context == null || context.Channel == null)
            {
                return(false);
            }

            IProgram      programNow;
            IProgram      programNext;
            ListItem      item;
            ILocalization localization = ServiceRegistration.Get <ILocalization>();
            bool          isRecording  = false;

            if (_tvHandler.ProgramInfo.GetNowNextProgram(context.Channel, out programNow, out programNext))
            {
                var recStatus = GetRecordingStatus(programNow);
                isRecording = recStatus.HasValue && recStatus.Value.HasFlag(RecordingStatus.Scheduled | RecordingStatus.Recording);
                item        = new ListItem(Consts.KEY_NAME, localization.ToString(isRecording ? "[SlimTvClient.StopCurrentRecording]" : "[SlimTvClient.RecordCurrentProgram]", programNow.Title))
                {
                    Command = new MethodDelegateCommand(() => CreateOrDeleteSchedule(programNow))
                };
                _dialogActionsList.Add(item);
            }
            if (!isRecording)
            {
                item = new ListItem(Consts.KEY_NAME, "[SlimTvClient.RecordManual]")
                {
                    Command = new MethodDelegateCommand(() => CreateOrDeleteSchedule(new Program
                    {
                        Title     = localization.ToString("[SlimTvClient.ManualRecordingTitle]"),
                        ChannelId = context.Channel.ChannelId,
                        StartTime = DateTime.Now,
                        EndTime   = DateTime.Now.AddDays(1)
                    }))
                };
                _dialogActionsList.Add(item);
            }
            _dialogActionsList.FireChange();
            return(true);
        }
        protected override void Update()
        {
            if (_updating)
            {
                return;
            }
            _updating = true;
            try
            {
                IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>();
                IPlayerContext        playerContext        = playerContextManager.GetPlayerContext(_playerContext);

                _currentMediaItem = playerContext == null ? null : playerContext.CurrentMediaItem;
                MediaItemAspect imageAspect;
                if (_currentMediaItem == null || !_currentMediaItem.Aspects.TryGetValue(ImageAspect.ASPECT_ID, out imageAspect))
                {
                    imageAspect = null;
                }

                if (imageAspect == null)
                {
                    ImageDimensions   = string.Empty;
                    CameraMake        = string.Empty;
                    CameraModel       = string.Empty;
                    ImageISOSpeed     = string.Empty;
                    ImageExposureTime = string.Empty;
                    ImageFNumber      = string.Empty;
                    ImageFlashMode    = string.Empty;
                    ImageMeteringMode = string.Empty;
                    Country           = string.Empty;
                    State             = string.Empty;
                    City = string.Empty;
                }
                else
                {
                    ImageDimensions   = String.Format("{0} x {1}", imageAspect[ImageAspect.ATTR_WIDTH], imageAspect[ImageAspect.ATTR_HEIGHT]);
                    CameraMake        = (string)imageAspect[ImageAspect.ATTR_MAKE];
                    CameraModel       = (string)imageAspect[ImageAspect.ATTR_MODEL];
                    ImageISOSpeed     = (string)imageAspect[ImageAspect.ATTR_ISO_SPEED];
                    ImageExposureTime = (string)imageAspect[ImageAspect.ATTR_EXPOSURE_TIME];
                    ImageFNumber      = (string)imageAspect[ImageAspect.ATTR_FNUMBER];
                    ImageFlashMode    = (string)imageAspect[ImageAspect.ATTR_FLASH_MODE];
                    ImageMeteringMode = (string)imageAspect[ImageAspect.ATTR_METERING_MODE];
                    Country           = (string)imageAspect[ImageAspect.ATTR_COUNTRY];
                    State             = (string)imageAspect[ImageAspect.ATTR_STATE];
                    City = (string)imageAspect[ImageAspect.ATTR_CITY];
                }
            }
            catch (Exception e)
            {
                ServiceRegistration.Get <ILogger>().Warn("ImagePlayerUIContributor: Error updating properties", e);
            }
            finally
            {
                _updating = false;
            }
        }
        public void ClosePlayerContext(int playerIndex)
        {
            IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>();
            IPlayerContext        pc = playerContextManager.GetPlayerContext(playerIndex);

            if (pc != null)
            {
                pc.Close();
            }
        }
        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);
                }
            }
        }
示例#18
0
        protected override void Update()
        {
            // base.Update is abstract
            IPlayerContextManager playerContextManager   = ServiceRegistration.Get <IPlayerContextManager>();
            IPlayerContext        secondaryPlayerContext = playerContextManager.GetPlayerContext(PlayerManagerConsts.SECONDARY_SLOT);
            IVideoPlayer          pipPlayer    = secondaryPlayerContext == null ? null : secondaryPlayerContext.CurrentPlayer as IVideoPlayer;
            IInputManager         inputManager = ServiceRegistration.Get <IInputManager>();

            IsOSDVisible = inputManager.IsMouseUsed || DateTime.Now - _lastVideoInfoDemand < Consts.TS_VIDEO_INFO_TIMEOUT || _inactive;
            IsPip        = pipPlayer != null;
        }
        private async Task <bool> InitActionsList()
        {
            _dialogActionsList.Clear();
            DialogHeader = "[SlimTvClient.RecordActions]";
            IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>();
            IPlayerContext        playerContext        = playerContextManager.GetPlayerContext(PlayerChoice.PrimaryPlayer);

            if (playerContext == null)
            {
                return(false);
            }
            LiveTvMediaItem liveTvMediaItem = playerContext.CurrentMediaItem as LiveTvMediaItem;
            LiveTvPlayer    player          = playerContext.CurrentPlayer as LiveTvPlayer;

            if (liveTvMediaItem == null || player == null)
            {
                return(false);
            }

            ITimeshiftContext context = player.TimeshiftContexes.LastOrDefault();

            if (context == null || context.Channel == null)
            {
                return(false);
            }

            ListItem      item;
            ILocalization localization = ServiceRegistration.Get <ILocalization>();
            bool          isRecording  = false;
            var           result       = await _tvHandler.ProgramInfo.GetNowNextProgramAsync(context.Channel);

            if (result.Success)
            {
                IProgram programNow = result.Result[0];
                var      recStatus  = await GetRecordingStatusAsync(programNow);

                isRecording = recStatus.HasValue && recStatus.Value.HasFlag(RecordingStatus.Scheduled | RecordingStatus.Recording);
                item        = new ListItem(Consts.KEY_NAME, localization.ToString(isRecording ? "[SlimTvClient.StopCurrentRecording]" : "[SlimTvClient.RecordCurrentProgram]", programNow.Title))
                {
                    Command = new AsyncMethodDelegateCommand(() => CreateOrDeleteSchedule(programNow))
                };
                _dialogActionsList.Add(item);
            }
            if (!isRecording)
            {
                item = new ListItem(Consts.KEY_NAME, "[SlimTvClient.RecordManual]")
                {
                    Command = new AsyncMethodDelegateCommand(() => CreateOrDeleteScheduleByTimeAsync(context.Channel, DateTime.Now, DateTime.Now.AddDays(1)))
                };
                _dialogActionsList.Add(item);
            }
            _dialogActionsList.FireChange();
            return(true);
        }
示例#20
0
        public void ClearPlaylist()
        {
            IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>();
            IPlayerContext        pc       = playerContextManager.GetPlayerContext(PlayerChoice.CurrentPlayer);
            IPlaylist             playlist = pc == null ? null : pc.Playlist;

            if (playlist == null)
            {
                return;
            }
            playlist.Clear();
        }
示例#21
0
        public void Execute()
        {
            IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>();
            IPlayerContext        pc = playerContextManager.GetPlayerContext(PlayerManagerConsts.PRIMARY_SLOT);

            if (pc == null)
            {
                return;
            }
            IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>();

            workflowManager.NavigatePush(pc.FullscreenContentWorkflowStateId);
        }
示例#22
0
        protected virtual bool RemoveItem(int index)
        {
            IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>();
            IPlayerContext        pc       = playerContextManager.GetPlayerContext(PlayerChoice.CurrentPlayer);
            IPlaylist             playlist = pc == null ? null : pc.Playlist;

            lock (_syncObj)
                if (pc == null || pc.Playlist != _playlist)
                {
                    return(false);
                }
            playlist.RemoveAt(index);
            return(true);
        }
示例#23
0
        protected virtual void PlayItem(int index)
        {
            IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>();
            IPlayerContext        pc       = playerContextManager.GetPlayerContext(PlayerChoice.CurrentPlayer);
            IPlaylist             playlist = pc == null ? null : pc.Playlist;

            lock (_syncObj)
                if (pc == null || pc.Playlist != _playlist)
                {
                    return;
                }
            playlist.ItemListIndex = index;
            pc.DoPlay(playlist.Current);
        }
示例#24
0
        private void SetPlayerBounds()
        {
            IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>();

            for (int index = 0; index < playerContextManager.NumActivePlayerContexts; index++)
            {
                IPlayerContext playerContext = playerContextManager.GetPlayerContext(index);
                if (playerContext != null && playerContext.CurrentPlayer is WebBrowserVideoPlayer)
                {
                    WebBrowserVideoPlayer webPlayer = (WebBrowserVideoPlayer)playerContext.CurrentPlayer;
                    webPlayer.TargetBounds = TransformBoundingBox(BoundingBox);
                }
            }
        }
示例#25
0
        private void OnMessageReceived(AsynchronousMessageQueue queue, SystemMessage message)
        {
            if (message.ChannelName == PlaylistMessaging.CHANNEL)
            {
                PlaylistMessaging.MessageType messageType = (PlaylistMessaging.MessageType)message.MessageType;
                switch (messageType)
                {
                case PlaylistMessaging.MessageType.PlaylistUpdate:
                    UpdatePlaylist();
                    break;

                case PlaylistMessaging.MessageType.CurrentItemChange:
                    UpdateCurrentItem();
                    break;

                case PlaylistMessaging.MessageType.PropertiesChange:
                    UpdateProperties();
                    break;
                }
            }
            else if (message.ChannelName == PlayerManagerMessaging.CHANNEL)
            {
                PlayerManagerMessaging.MessageType messageType = (PlayerManagerMessaging.MessageType)message.MessageType;
                switch (messageType)
                {
                case PlayerManagerMessaging.MessageType.PlayerSlotClosed:
                    IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>();
                    ISystemStateService   sss = ServiceRegistration.Get <ISystemStateService>();
                    IPlayerContext        pc  = playerContextManager.GetPlayerContext(PlayerChoice.CurrentPlayer);
                    if (pc == null && sss.CurrentState == SystemState.Running)
                    {
                        IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>();
                        workflowManager.NavigatePopToState(Consts.WF_STATE_ID_SHOW_PLAYLIST, true);
                    }
                    break;
                    // We don't need to track the PlayerSlotActivated or PlayerSlotsChanged messages, because all information
                    // we need is contained in the CurrentPlayer information
                }
            }
            else if (message.ChannelName == PlayerContextManagerMessaging.CHANNEL)
            {
                PlayerContextManagerMessaging.MessageType messageType = (PlayerContextManagerMessaging.MessageType)message.MessageType;
                switch (messageType)
                {
                case PlayerContextManagerMessaging.MessageType.CurrentPlayerChanged:
                    UpdatePlaylist();
                    break;
                }
            }
        }
示例#26
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);
                }
            }
        }
        protected void UpdateAudioStreamsMenu()
        {
            // Some updates could be avoided if we tracked a "dirty" flag and break execution if !dirty
            lock (_syncObj)
            {
                IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>();
                int numActivePlayers     = playerContextManager.NumActivePlayerContexts;
                int numberOfAudioStreams = GetTotalNumberOfAudioStreams();

                _audioStreamsMenu.Clear();
                for (int i = 0; i < numActivePlayers; i++)
                {
                    IPlayerContext pc = playerContextManager.GetPlayerContext(i);
                    if (pc == null || !pc.IsActive)
                    {
                        continue;
                    }
                    IPlayer player = pc.CurrentPlayer;
                    AudioStreamDescriptor         currentAudioStream;
                    IList <AudioStreamDescriptor> asds = new List <AudioStreamDescriptor>(pc.GetAudioStreamDescriptors(out currentAudioStream));
                    foreach (AudioStreamDescriptor asd in asds)
                    {
                        string playedItem = player == null ? null : player.MediaItemTitle ?? pc.Name;
                        string choiceItemName;
                        int    count = asds.Count;
                        if (numActivePlayers > 1 && count > 1 && count != numberOfAudioStreams)
                        {
                            // Only display the playedItem name if more than one player is able to provide audio streams. If a single player provides
                            // multiple streams, they will be distinguished by the VideoPlayer.
                            choiceItemName = playedItem + ": " + asd.AudioStreamName;
                        }
                        else
                        {
                            choiceItemName = count != numberOfAudioStreams ? playedItem : asd.AudioStreamName;
                        }

                        AudioStreamDescriptor asdClosureCopy = asd;
                        ListItem item = new ListItem(Consts.KEY_NAME, choiceItemName)
                        {
                            Command  = new MethodDelegateCommand(() => ChooseAudioStream(asdClosureCopy)),
                            Selected = asd == currentAudioStream,
                        };
                        item.AdditionalProperties[Consts.KEY_NAVIGATION_MODE] = NavigationMode.ExitPCWorkflow;
                        _audioStreamsMenu.Add(item);
                    }
                }
                _audioStreamsMenu.FireChange();
            }
        }
示例#28
0
        private MediaItem GetCurrentMediaItem(IVideoPlayer player)
        {
            IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>();

            for (int index = 0; index < playerContextManager.NumActivePlayerContexts; index++)
            {
                IPlayerContext playerContext = playerContextManager.GetPlayerContext(index);
                if (playerContext == null || playerContext.CurrentPlayer != player)
                {
                    continue;
                }
                return(playerContext.CurrentMediaItem);
            }
            return(null);
        }
        protected IList <IPlayerContext> GetVideoPlayerContexts()
        {
            IPlayerContextManager  pcm      = ServiceRegistration.Get <IPlayerContextManager>();
            IList <IPlayerContext> videoPCs = new List <IPlayerContext>();

            for (int i = 0; i < pcm.NumActivePlayerContexts; i++)
            {
                IPlayerContext pc = pcm.GetPlayerContext(i);
                if (pc != null && pc.CurrentPlayer is IVideoPlayer)
                {
                    videoPCs.Add(pc);
                }
            }
            return(videoPCs);
        }
        private static bool GetPlayerWorkflowStates(out Guid?fullscreenContentWfStateId, out Guid?currentlyPlayingWorkflowStateId)
        {
            IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>();
            IPlayerContext        playerContext        = playerContextManager.GetPlayerContext(PlayerChoice.CurrentPlayer);

            if (playerContext == null)
            {
                fullscreenContentWfStateId      = null;
                currentlyPlayingWorkflowStateId = null;
                return(false);
            }

            fullscreenContentWfStateId      = playerContext.FullscreenContentWorkflowStateId;
            currentlyPlayingWorkflowStateId = playerContext.CurrentlyPlayingWorkflowStateId;
            return(true);
        }
 /// <summary>
 /// Gets a name for a player context.
 /// </summary>
 /// <param name="playerContextManager">Player context manager.</param>
 /// <param name="playerSlot">Number of the player slot, <c>0</c> to <c>1</c>.</param>
 /// <returns></returns>
 protected static string GetNameForPlayerContext(IPlayerContextManager playerContextManager, int playerSlot)
 {
   IPlayerContext pc = playerContextManager.GetPlayerContext(playerSlot);
   if (pc == null)
     return null;
   IPlayer player = pc.CurrentPlayer;
   if (player == null)
   {
     IResourceString playerOfType = LocalizationHelper.CreateResourceString(Consts.RES_PLAYER_OF_TYPE); // "{0} player"
     IResourceString slotNo = LocalizationHelper.CreateResourceString(Consts.RES_SLOT_NO); // "Slot #{0}"
     return playerOfType.Evaluate(pc.AVType.ToString()) + " (" + slotNo.Evaluate((playerSlot + 1).ToString()) + ")"; // "Video player (Slot #1)"
   }
   return player.Name + ": " + player.MediaItemTitle;
 }