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(() => CreateOrDeleteScheduleByTime(context.Channel, DateTime.Now, DateTime.Now.AddDays(1)))
                };
                _dialogActionsList.Add(item);
            }
            _dialogActionsList.FireChange();
            return(true);
        }
示例#2
0
        protected void Update()
        {
            bool oldVisible = _isVisible;

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

            _isVisible = playerContextManager.NumActivePlayerContexts > 0;
            if (oldVisible != _isVisible)
            {
                FireStateChanged();
            }
        }
示例#3
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();
        }
示例#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;
                    IChannel          channel        = null;
                    if (context != null && context.Channel != null)
                    {
                        channel         = context.Channel;
                        ChannelName     = channel.Name;
                        ChannelLogoType = channel.GetFanArtMediaType();
                        if (_tvHandler.ProgramInfo != null && _tvHandler.ProgramInfo.GetNowNextProgram(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, channel);
                    NextProgram.SetProgram(nextProgram, channel);
                }
            }
        }
        public void Execute()
        {
            IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>();
            IPlayerContext        pc = playerContextManager.CurrentPlayerContext;

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

            workflowManager.NavigatePush(pc.CurrentlyPlayingWorkflowStateId);
        }
示例#6
0
        protected virtual bool GetPlayer(out ISharpDXVideoPlayer player)
        {
            player = null;
            IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>(false);

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

            player = playerContextManager[Stream] as ISharpDXVideoPlayer;
            return(player != null);
        }
        public void Execute()
        {
            IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>();
            IPlayerContext        pc = playerContextManager.PrimaryPlayerContext;

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

            workflowManager.NavigatePush(pc.FullscreenContentWorkflowStateId);
        }
        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;
                }
                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];
                }
            }
            catch (Exception e)
            {
                ServiceRegistration.Get <ILogger>().Warn("ImagePlayerUIContributor: Error updating properties", e);
            }
            finally
            {
                _updating = false;
            }
        }
        protected void Update()
        {
            IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>();
            IWorkflowManager      workflowManager      = ServiceRegistration.Get <IWorkflowManager>();
            IPlayerContext        pc = playerContextManager.CurrentPlayerContext;
            bool visible             = pc != null && !workflowManager.IsStateContainedInNavigationStack(pc.CurrentlyPlayingWorkflowStateId);

            if (visible == _isVisible)
            {
                return;
            }
            _isVisible = visible;
            FireStateChanged();
        }
示例#10
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);
                }
            }
        }
示例#11
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);
        }
示例#12
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);
        }
示例#13
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;
                }
            }
        }
        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]);
                            }
                        }
                    }
                }
            }
        }
        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();
            }
        }
        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);
        }
示例#17
0
        protected static void CompletePlayOrEnqueue(IPlayerContext pc, bool play)
        {
            IPlayerContextManager pcm      = ServiceRegistration.Get <IPlayerContextManager>();
            MediaModelSettings    settings = ServiceRegistration.Get <ISettingsManager>().Load <MediaModelSettings>();

            pc.CloseWhenFinished = settings.ClosePlayerWhenFinished; // Has to be done before starting the media item, else the slot will not close in case of an error / when the media item cannot be played
            if (play)
            {
                pc.Play();
                if (pc.AVType == AVType.Video)
                {
                    pcm.ShowFullscreenContent(true);
                }
            }
        }
示例#18
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);
        }
示例#19
0
        private void OnApplicationIdle(object sender, EventArgs e)
        {
            try
            {
                // Screen saver
                IInputManager inputManager = ServiceRegistration.Get <IInputManager>();
                // Remember old state, calls to IScreenManager are only required on state changes
                bool wasScreenSaverActive = _isScreenSaverActive;
                if (_isScreenSaverEnabled)
                {
                    IPlayerManager        playerManager        = ServiceRegistration.Get <IPlayerManager>();
                    IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>();
                    IPlayer primaryPlayer     = playerManager[PlayerManagerConsts.PRIMARY_SLOT];
                    IMediaPlaybackControl mbc = primaryPlayer as IMediaPlaybackControl;
                    bool preventScreenSaver   = ((primaryPlayer is IVideoPlayer || primaryPlayer is IImagePlayer) && (mbc == null || !mbc.IsPaused)) ||
                                                playerContextManager.IsFullscreenContentWorkflowStateActive;

                    _isScreenSaverActive = !preventScreenSaver &&
                                           SkinContext.FrameRenderingStartTime - inputManager.LastMouseUsageTime > _screenSaverTimeOut &&
                                           SkinContext.FrameRenderingStartTime - inputManager.LastInputTime > _screenSaverTimeOut;

                    if (_screenSaverController != null)
                    {
                        bool?activeOverride = _screenSaverController.IsScreenSaverActiveOverride;
                        if (activeOverride.HasValue)
                        {
                            _isScreenSaverActive = activeOverride.Value;
                        }
                    }
                }
                else
                {
                    _isScreenSaverActive = false;
                }
                if (wasScreenSaverActive != _isScreenSaverActive)
                {
                    IScreenManager superLayerManager = ServiceRegistration.Get <IScreenManager>();
                    superLayerManager.SetSuperLayer(_isScreenSaverActive ? SCREEN_SAVER_SCREEN : null);
                }

                // If we are in fullscreen mode, we may control the mouse cursor, else reset it to visible state, if state was switched
                ShowMouseCursor(!IsFullScreen || inputManager.IsMouseUsed);
            }
            catch (Exception ex)
            {
                ServiceRegistration.Get <ILogger>().Error("SkinEngine MainForm: Error occured in Idle handler", ex);
            }
        }
        protected override IVideoPlayer GetPlayerToSynchronize()
        {
            IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>();

            foreach (var index in new[] { PlayerContextIndex.PRIMARY, PlayerContextIndex.SECONDARY })
            {
                IVideoPlayer player = playerContextManager[index] as IVideoPlayer;
                // Note: once the player "Ended", the PCM might still have a reference to this player (due to asynchronous message delivery),
                // so we check that the player is active. Otherwise we return null to disable synchronization with that player.
                if (player != null && player.State == PlayerState.Active)
                {
                    return(player);
                }
            }
            return(null);
        }
        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);
        }
示例#22
0
        PlaylistItem GetOnlineVideosMediaItemFromPlayerContexts()
        {
            IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>();

            for (int index = 0; index < playerContextManager.NumActivePlayerContexts; index++)
            {
                IPlayerContext playerContext = playerContextManager.GetPlayerContext(index);
                if (playerContext != null &&
                    playerContext.CurrentMediaItem is PlaylistItem &&
                    playerContext.CurrentMediaItem.GetResourceLocator().NativeResourcePath == _resourceLocator.NativeResourcePath)
                {
                    return(playerContext.CurrentMediaItem as PlaylistItem);
                }
            }
            return(null);
        }
示例#23
0
        protected IPlayerContext GetPlayerContext(MediaWorkflowStateType stateType)
        {
            IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>();

            if (stateType == MediaWorkflowStateType.CurrentlyPlaying)
            {
                // The "currently playing" screen is always bound to the "current player"
                return(playerContextManager.CurrentPlayerContext);
            }
            if (stateType == MediaWorkflowStateType.FullscreenContent)
            {
                // The "fullscreen content" screen is always bound to the "primary player"
                return(playerContextManager.PrimaryPlayerContext);
            }
            return(null);
        }
        public static void SaveCurrentPlaylist()
        {
            IPlayerContextManager pcm      = ServiceRegistration.Get <IPlayerContextManager>();
            IPlayerContext        pc       = pcm.GetPlayerContext(PlayerChoice.CurrentPlayer);
            IPlaylist             playlist = pc == null ? null : pc.Playlist;

            if (playlist == null)
            {
                ServiceRegistration.Get <ILogger>().Warn("ManagePlaylistsModel: No playlist available to save");
                return;
            }
            PlaylistRawData playlistData = new PlaylistRawData(Guid.NewGuid(), string.Empty, ConvertAVTypeToPlaylistType(pc.AVType));

            playlist.ExportPlaylistRawData(playlistData);
            SavePlaylist(playlistData);
        }
示例#25
0
        /// <summary>
        /// Depending on parameter <paramref name="play"/>, plays or enqueues the specified media <paramref name="item"/>.
        /// </summary>
        /// <param name="item">Media item to be played.</param>
        /// <param name="play">If <c>true</c>, plays the specified <paramref name="item"/>, else enqueues it.</param>
        /// <param name="concurrencyMode">Determines if the media item will be played or enqueued in concurrency mode.</param>
        public static void PlayOrEnqueueItem(MediaItem item, bool play, PlayerContextConcurrencyMode concurrencyMode)
        {
            IPlayerContextManager pcm = ServiceRegistration.Get <IPlayerContextManager>();
            AVType         avType     = pcm.GetTypeOfMediaItem(item);
            IPlayerContext pc         = PreparePlayerContext(avType, play, concurrencyMode);

            if (pc == null)
            {
                return;
            }

            // Always add items to playlist. This allows audio playlists as well as video/image playlists.
            pc.Playlist.Add(item);

            ServiceRegistration.Get <IThreadPool>().Add(() => CompletePlayOrEnqueue(pc, play));
        }
示例#26
0
        /// <summary>
        /// Depending on parameter <paramref name="play"/>, plays or enqueues the specified media <paramref name="item"/>.
        /// </summary>
        /// <param name="item">Media item to be played.</param>
        /// <param name="play">If <c>true</c>, plays the specified <paramref name="item"/>, else enqueues it.</param>
        /// <param name="concurrencyMode">Determines if the media item will be played or enqueued in concurrency mode.</param>
        /// <param name="resumeState">Contains optional information for players to resume playback.</param>
        public static async Task PlayOrEnqueueItem(MediaItem item, bool play, PlayerContextConcurrencyMode concurrencyMode, IResumeState resumeState = null)
        {
            IPlayerContextManager pcm = ServiceRegistration.Get <IPlayerContextManager>();
            AVType         avType     = pcm.GetTypeOfMediaItem(item);
            IPlayerContext pc         = PreparePlayerContext(avType, play, concurrencyMode);

            if (pc == null)
            {
                return;
            }

            // Always add items to playlist. This allows audio playlists as well as video/image playlists.
            pc.Playlist.Add(item);

            await CompletePlayOrEnqueue(pc, play, resumeState);
        }
示例#27
0
 void OnMessageReceived(AsynchronousMessageQueue queue, SystemMessage message)
 {
     if (message.ChannelName == RemovableMediaMessaging.CHANNEL)
     {
         RemovableMediaMessaging.MessageType messageType = (RemovableMediaMessaging.MessageType)message.MessageType;
         if (messageType == RemovableMediaMessaging.MessageType.MediaInserted)
         {
             string drive = (string)message.MessageData[RemovableMediaMessaging.DRIVE_LETTER];
             var    type  = ExamineVolume(drive);
             if (_removableMediaItems.TryGetValue(drive, out var items))
             {
                 PlayItemsModel.AddOrUpdateRemovableMediaItems(items);
             }
             RemovableMediaManagerSettings settings = ServiceRegistration.Get <ISettingsManager>().Load <RemovableMediaManagerSettings>();
             if (settings.AutoPlay == AutoPlayType.AutoPlay)
             {
                 IPlayerContextManager pcm = ServiceRegistration.Get <IPlayerContextManager>();
                 if (!pcm.IsFullscreenContentWorkflowStateActive)
                 {
                     CheckAutoPlay(drive, type);
                 }
             }
         }
         else if (messageType == RemovableMediaMessaging.MessageType.MediaRemoved)
         {
             string drive = (string)message.MessageData[RemovableMediaMessaging.DRIVE_LETTER];
             IEnumerable <MediaItem> items;
             if (_removableMediaItems.TryRemove(drive, out items))
             {
                 PlayItemsModel.RemoveRemovableMediaItems(items);
             }
             if (_removableMediaItems.TryRemove(drive + @"\", out items))
             {
                 PlayItemsModel.RemoveRemovableMediaItems(items);
             }
         }
     }
     else if (message.ChannelName == ServerConnectionMessaging.CHANNEL)
     {
         ServerConnectionMessaging.MessageType messageType = (ServerConnectionMessaging.MessageType)message.MessageType;
         if (messageType == ServerConnectionMessaging.MessageType.HomeServerConnected && _runStartupCheck)
         {
             _runStartupCheck = false;
             StartupCheck();
         }
     }
 }
        protected int GetTotalNumberOfAudioStreams()
        {
            int numberOfAudioStreams = 0;
            IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>();

            for (int i = 0; i < playerContextManager.NumActivePlayerContexts; i++)
            {
                IPlayerContext pc = playerContextManager.GetPlayerContext(i);
                if (pc == null || !pc.IsActive)
                {
                    continue;
                }
                AudioStreamDescriptor currentAudioStream;
                numberOfAudioStreams += pc.GetAudioStreamDescriptors(out currentAudioStream).Count;
            }
            return(numberOfAudioStreams);
        }
示例#29
0
 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;
         }
     }
     else if (message.ChannelName == ServerStateMessaging.CHANNEL)
     {
         //Check if Tv Server state has changed and update if necessary
         ServerStateMessaging.MessageType messageType = (ServerStateMessaging.MessageType)message.MessageType;
         if (messageType == ServerStateMessaging.MessageType.StatesChanged)
         {
             var states = message.MessageData[ServerStateMessaging.STATES] as IDictionary <Guid, object>;
             if (states != null && states.ContainsKey(TvServerState.STATE_ID))
             {
                 ServerState = states[TvServerState.STATE_ID] as TvServerState;
             }
         }
     }
 }
示例#30
0
        private void CheckVideoResolution(object sender, ElapsedEventArgs e)
        {
            IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>(false);

            if (playerContextManager == null)
            {
                return;
            }
            for (int index = 0; index < playerContextManager.NumActivePlayerContexts; index++)
            {
                IPlayerContext playerContext = playerContextManager.GetPlayerContext(index);
                if (playerContext == null || playerContext.PlayerSlotController == null)
                {
                    continue;
                }
                HandleVideoEffectSelection(playerContext.PlayerSlotController);
            }
        }
 /// <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;
 }