protected Task CheckQueryPlayAction_ShowMediaTypeChoice(GetMediaItemsDlgt getMediaItemsFunction)
        {
            _mediaTypeChoiceMenuItems = new ItemsList
            {
                new ListItem(Consts.KEY_NAME, Consts.RES_ADD_ALL_AUDIO)
                {
                    Command = new MethodDelegateCommand(() => CheckQueryPlayAction_Continue(
                                                            getMediaItemsFunction, new Guid[] { AudioAspect.Metadata.AspectId }, AVType.Audio))
                },
                new ListItem(Consts.KEY_NAME, Consts.RES_ADD_ALL_VIDEOS)
                {
                    Command = new MethodDelegateCommand(() => CheckQueryPlayAction_Continue(
                                                            getMediaItemsFunction, new Guid[] { VideoAspect.Metadata.AspectId }, AVType.Video))
                },
                new ListItem(Consts.KEY_NAME, Consts.RES_ADD_ALL_IMAGES)
                {
                    Command = new MethodDelegateCommand(() => CheckQueryPlayAction_Continue(
                                                            getMediaItemsFunction, new Guid[] { ImageAspect.Metadata.AspectId }, AVType.Video))
                },
                new ListItem(Consts.KEY_NAME, Consts.RES_ADD_VIDEOS_AND_IMAGES)
                {
                    Command = new MethodDelegateCommand(() => CheckQueryPlayAction_Continue(
                                                            getMediaItemsFunction, new Guid[] { VideoAspect.Metadata.AspectId, ImageAspect.Metadata.AspectId }, AVType.Video))
                },
            };
            IScreenManager screenManager = ServiceRegistration.Get <IScreenManager>();

            screenManager.ShowDialog(Consts.DIALOG_CHOOSE_AV_TYPE, (dialogName, dialogInstanceId) => LeaveQueryAVTypeState());
            return(Task.CompletedTask);
        }
Beispiel #2
0
        /// <summary>
        /// Discards any current player and plays the media items of type <paramref name="avType"/> returned by the given
        /// <paramref name="getMediaItemsFunction"/>.
        /// </summary>
        /// <param name="getMediaItemsFunction">Function returning the media items to be played.</param>
        /// <param name="avType">AV type of media items returned.</param>
        public static void PlayItems(GetMediaItemsDlgt getMediaItemsFunction, AVType avType)
        {
            IPlayerManager playerManager = ServiceRegistration.Get <IPlayerManager>();

            playerManager.CloseSlot(PlayerManagerConsts.SECONDARY_SLOT);
            PlayOrEnqueueItems(getMediaItemsFunction, avType, true, PlayerContextConcurrencyMode.None);
        }
Beispiel #3
0
        protected void AddCurrentViewToPlaylistInternal(MediaItem selectedMediaItem)
        {
            NavigationData navigationData = NavigationData;

            if (navigationData == null || !navigationData.IsEnabled)
            {
                ServiceRegistration.Get <ILogger>().Error("MediaNavigationModel: Cannot add current view to playlist - There is no enabled navigation data available");
            }
            string            mode = Mode;
            GetMediaItemsDlgt getMediaItemsWithSelection = () => GetMediaItemsFromCurrentView(selectedMediaItem);

            switch (mode)
            {
            case MediaNavigationMode.Audio:
                PlayItemsModel.CheckQueryPlayAction(getMediaItemsWithSelection, AVType.Audio);
                break;

            case MediaNavigationMode.Movies:
            case MediaNavigationMode.Series:
            case MediaNavigationMode.Videos:
            case MediaNavigationMode.Images:
                PlayItemsModel.CheckQueryPlayAction(getMediaItemsWithSelection, AVType.Video);
                break;

            case MediaNavigationMode.BrowseLocalMedia:
            case MediaNavigationMode.BrowseMediaLibrary:
                PlayItemsModel.CheckQueryPlayAction(getMediaItemsWithSelection);
                break;
            }
        }
Beispiel #4
0
        protected void PrepareState(NavigationContext context)
        {
            Guid workflowStateId = context.WorkflowState.StateId;

            if (workflowStateId == Consts.WF_STATE_ID_PLAY_OR_ENQUEUE_ITEMS)
            {
                AVType            avType = (AVType)context.GetContextVariable(KEY_AV_TYPE, false);
                GetMediaItemsDlgt getMediaItemsFunction = (GetMediaItemsDlgt)context.GetContextVariable(KEY_GET_MEDIA_ITEMS_FUNCTION, false);
                bool doPlay = (bool)context.GetContextVariable(KEY_DO_PLAY, false);
                PlayerContextConcurrencyMode concurrencyMode = (PlayerContextConcurrencyMode)context.GetContextVariable(KEY_CONCURRENCY_MODE, false);
                PlayOrEnqueueItemsInternal(getMediaItemsFunction, avType, doPlay, concurrencyMode);
            }
            else if (workflowStateId == Consts.WF_STATE_ID_CHECK_RESUME_SINGLE_ITEM)
            {
                MediaItem item = (MediaItem)context.GetContextVariable(KEY_MEDIA_ITEM, false);
                CheckResumeMenuInternal(item);
            }
            else if (workflowStateId == Consts.WF_STATE_ID_CHECK_QUERY_PLAYACTION_SINGLE_ITEM)
            {
                MediaItem item = (MediaItem)context.GetContextVariable(KEY_MEDIA_ITEM, false);
                CheckPlayMenuInternal(item);
            }
            else if (workflowStateId == Consts.WF_STATE_ID_CHECK_QUERY_PLAYACTION_MULTIPLE_ITEMS)
            {
                GetMediaItemsDlgt getMediaItemsFunction = (GetMediaItemsDlgt)context.GetContextVariable(KEY_GET_MEDIA_ITEMS_FUNCTION, false);
                AVType            avType = (AVType)context.GetContextVariable(KEY_AV_TYPE, false);
                CheckPlayMenuInternal(getMediaItemsFunction, avType);
            }
            else if (workflowStateId == Consts.WF_STATE_ID_QUERY_AV_TYPE_CHECK_QUERY_PLAYACTION_MULTIPLE_ITEMS)
            {
                GetMediaItemsDlgt getMediaItemsFunction = (GetMediaItemsDlgt)context.GetContextVariable(KEY_GET_MEDIA_ITEMS_FUNCTION, false);
                CheckQueryPlayAction_ShowMediaTypeChoice(getMediaItemsFunction);
            }
        }
        protected async Task AsyncAddToPlaylist(IPlayerContext pc, GetMediaItemsDlgt getMediaItemsFunction, bool play)
        {
            IScreenManager screenManager    = ServiceRegistration.Get <IScreenManager>();
            Guid?          dialogInstanceId = screenManager.ShowDialog(Consts.DIALOG_ADD_TO_PLAYLIST_PROGRESS,
                                                                       (dialogName, instanceId) => StopAddToPlaylist());

            try
            {
                int numItems = 0;
                _stopAddToPlaylist = false;
                SetNumItemsAddedToPlaylist(0);
                ICollection <MediaItem> items = new List <MediaItem>();
                foreach (MediaItem item in getMediaItemsFunction())
                {
                    SetNumItemsAddedToPlaylist(++numItems);
                    if (_stopAddToPlaylist)
                    {
                        break;
                    }
                    items.Add(item);
                }
                pc.Playlist.AddAll(items);
            }
            finally
            {
                if (dialogInstanceId.HasValue)
                {
                    screenManager.CloseDialog(dialogInstanceId.Value);
                }
                IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>();
                workflowManager.NavigatePopToState(Consts.WF_STATE_ID_PLAY_OR_ENQUEUE_ITEMS, true);
            }
            // Must be done after the dialog is closed
            await CompletePlayOrEnqueue(pc, play);
        }
        /// <summary>
        /// First shows a menu to choose which media type should be played (Video, Audio, Image), then
        /// filters the items returned from the given <paramref name="getMediaItemsFunction"/>, checks if we need to show a
        /// menu for playing those items and shows that menu or adds all items to the playlist at once, starting playing,
        /// if no player is active and thus no menu needs to be shown.
        /// </summary>
        /// <param name="getMediaItemsFunction">Function which returns the media items to be added to the playlist. This function
        /// might take some time to return the items; in that case, a progress dialog will be shown.</param>
        public static void CheckQueryPlayAction(GetMediaItemsDlgt getMediaItemsFunction)
        {
            IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>();

            workflowManager.NavigatePush(Consts.WF_STATE_ID_QUERY_AV_TYPE_CHECK_QUERY_PLAYACTION_MULTIPLE_ITEMS, new NavigationContextConfig
            {
                AdditionalContextVariables = new Dictionary <string, object>
                {
                    { KEY_GET_MEDIA_ITEMS_FUNCTION, getMediaItemsFunction },
                }
            });
        }
Beispiel #7
0
        protected void PlayOrEnqueueItemsInternal(GetMediaItemsDlgt getMediaItemsFunction, AVType avType,
                                                  bool play, PlayerContextConcurrencyMode concurrencyMode)
        {
            IPlayerContext pc = PreparePlayerContext(avType, play, concurrencyMode);

            if (pc == null)
            {
                return;
            }

            // Adding items to playlist must be executed asynchronously - we will show a progress dialog where we aren't allowed
            // to block the input thread.
            IThreadPool threadPool = ServiceRegistration.Get <IThreadPool>();

            threadPool.Add(() => AsyncAddToPlaylist(pc, getMediaItemsFunction, play));
        }
Beispiel #8
0
        /// <summary>
        /// Depending on parameter <paramref name="play"/>, plays or enqueues the media items of type <paramref name="avType"/>
        /// returned by the given <paramref name="getMediaItemsFunction"/>.
        /// This method can also be called from other models.
        /// </summary>
        /// <param name="getMediaItemsFunction">Function returning the media items to be played.</param>
        /// <param name="avType">AV type of media items to be played.</param>
        /// <param name="play">If <c>true</c>, plays the specified items, else enqueues it.</param>
        /// <param name="concurrencyMode">Determines if the media item will be played or enqueued in concurrency mode.</param>
        public static void PlayOrEnqueueItems(GetMediaItemsDlgt getMediaItemsFunction, AVType avType,
                                              bool play, PlayerContextConcurrencyMode concurrencyMode)
        {
            IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>();

            workflowManager.NavigatePush(Consts.WF_STATE_ID_PLAY_OR_ENQUEUE_ITEMS, new NavigationContextConfig
            {
                AdditionalContextVariables = new Dictionary <string, object>
                {
                    { KEY_GET_MEDIA_ITEMS_FUNCTION, getMediaItemsFunction },
                    { KEY_AV_TYPE, avType },
                    { KEY_DO_PLAY, play },
                    { KEY_CONCURRENCY_MODE, concurrencyMode },
                }
            });
        }
        protected async Task PlayOrEnqueueItemsInternal(GetMediaItemsDlgt getMediaItemsFunction, AVType avType,
                                                        bool play, PlayerContextConcurrencyMode concurrencyMode)
        {
            IPlayerContext pc = PreparePlayerContext(avType, play, concurrencyMode);

            if (pc == null)
            {
                return;
            }

            // Adding items to playlist must be executed asynchronously - we will show a progress dialog where we aren't allowed
            // to block the input thread.
            //await Task.Yield();
            await Task.Run(async() =>
            {
                await AsyncAddToPlaylist(pc, getMediaItemsFunction, play);
            });
        }
        public void AddMediaItemstoPlaylist(GetMediaItemsDlgt getMediaItemsWithSelection)
        {
            string mode = Mode;

            switch (mode)
            {
            case MediaNavigationMode.Audio:
                PlayItemsModel.CheckQueryPlayAction(getMediaItemsWithSelection, AVType.Audio);
                break;

            case MediaNavigationMode.Movies:
            case MediaNavigationMode.Series:
            case MediaNavigationMode.Videos:
            case MediaNavigationMode.Images:
                PlayItemsModel.CheckQueryPlayAction(getMediaItemsWithSelection, AVType.Video);
                break;

            case MediaNavigationMode.BrowseLocalMedia:
            case MediaNavigationMode.BrowseMediaLibrary:
                PlayItemsModel.CheckQueryPlayAction(getMediaItemsWithSelection);
                break;
            }
        }
 /// <summary>
 /// Discards any current player and plays the media items of type <paramref name="avType"/> returned by the given
 /// <paramref name="getMediaItemsFunction"/>.
 /// </summary>
 /// <param name="getMediaItemsFunction">Function returning the media items to be played.</param>
 /// <param name="avType">AV type of media items returned.</param>
 public static void PlayItems(GetMediaItemsDlgt getMediaItemsFunction, AVType avType)
 {
   IPlayerManager playerManager = ServiceRegistration.Get<IPlayerManager>();
   playerManager.CloseSlot(PlayerManagerConsts.SECONDARY_SLOT);
   PlayOrEnqueueItems(getMediaItemsFunction, avType, true, PlayerContextConcurrencyMode.None);
 }
 protected void CheckQueryPlayAction_Continue(GetMediaItemsDlgt getMediaItemsFunction,
                                              ICollection <Guid> consideredMediaItemAspectTypes, AVType avType)
 {
     LeaveQueryAVTypeState();
     CheckQueryPlayAction(() => FilterMediaItems(getMediaItemsFunction, consideredMediaItemAspectTypes), avType);
 }
 protected IEnumerable <MediaItem> FilterMediaItems(GetMediaItemsDlgt getMediaItemsFunction, ICollection <Guid> consideredMediaItemAspectTypes)
 {
     return(getMediaItemsFunction().Where(mediaItem => consideredMediaItemAspectTypes.Any(aspectType => mediaItem.Aspects.ContainsKey(aspectType))));
 }
Beispiel #14
0
 /// <summary>
 /// Discards any current player and plays the media items of type <paramref name="avType"/> returned by the given
 /// <paramref name="getMediaItemsFunction"/>.
 /// </summary>
 /// <param name="getMediaItemsFunction">Function returning the media items to be played.</param>
 /// <param name="avType">AV type of media items returned.</param>
 public static void PlayItems(GetMediaItemsDlgt getMediaItemsFunction, AVType avType)
 {
   CloseSecondaryPlayerContext();
   PlayOrEnqueueItems(getMediaItemsFunction, avType, true, PlayerContextConcurrencyMode.None);
 }
        protected async Task CheckPlayMenuInternal(GetMediaItemsDlgt getMediaItemsFunction, AVType avType)
        {
            IPlayerContextManager pcm = ServiceRegistration.Get <IPlayerContextManager>();
            int numOpen = pcm.NumActivePlayerContexts;

            if (numOpen == 0)
            {
                // Asynchronously leave the current workflow state because we're called from a workflow model method
                //await Task.Yield();
                await Task.Run(async() =>
                {
                    LeaveCheckQueryPlayActionMultipleItemsState();
                    await PlayItems(getMediaItemsFunction, avType);
                });

                return;
            }
            _playMenuItems = new ItemsList();
            int numAudio = pcm.GetPlayerContextsByAVType(AVType.Audio).Count();
            int numVideo = pcm.GetPlayerContextsByAVType(AVType.Video).Count();

            switch (avType)
            {
            case AVType.Audio:
            {
                ListItem playItem = new ListItem(Consts.KEY_NAME, Consts.RES_PLAY_AUDIO_ITEMS)
                {
                    Command = new AsyncMethodDelegateCommand(() =>
                        {
                            LeaveCheckQueryPlayActionMultipleItemsState();
                            return(PlayItems(getMediaItemsFunction, avType));
                        })
                };
                _playMenuItems.Add(playItem);
                if (numAudio > 0)
                {
                    ListItem enqueueItem = new ListItem(Consts.KEY_NAME, Consts.RES_ENQUEUE_AUDIO_ITEMS)
                    {
                        Command = new AsyncMethodDelegateCommand(() =>
                            {
                                LeaveCheckQueryPlayActionMultipleItemsState();
                                return(PlayOrEnqueueItems(getMediaItemsFunction, avType, false, PlayerContextConcurrencyMode.None));
                            })
                    };
                    _playMenuItems.Add(enqueueItem);
                }
                if (numVideo > 0)
                {
                    ListItem playItemConcurrently = new ListItem(Consts.KEY_NAME, Consts.RES_MUTE_VIDEO_PLAY_AUDIO_ITEMS)
                    {
                        Command = new AsyncMethodDelegateCommand(() =>
                            {
                                LeaveCheckQueryPlayActionMultipleItemsState();
                                return(PlayOrEnqueueItems(getMediaItemsFunction, avType, true, PlayerContextConcurrencyMode.ConcurrentVideo));
                            })
                    };
                    _playMenuItems.Add(playItemConcurrently);
                }
            }
            break;

            case AVType.Video:
            {
                ListItem playItem = new ListItem(Consts.KEY_NAME, Consts.RES_PLAY_VIDEO_IMAGE_ITEMS)
                {
                    Command = new AsyncMethodDelegateCommand(() =>
                        {
                            LeaveCheckQueryPlayActionMultipleItemsState();
                            return(PlayItems(getMediaItemsFunction, avType));
                        })
                };
                _playMenuItems.Add(playItem);
                if (numVideo > 0)
                {
                    ListItem enqueueItem = new ListItem(Consts.KEY_NAME, Consts.RES_ENQUEUE_VIDEO_IMAGE_ITEMS)
                    {
                        Command = new AsyncMethodDelegateCommand(() =>
                            {
                                LeaveCheckQueryPlayActionMultipleItemsState();
                                return(PlayOrEnqueueItems(getMediaItemsFunction, avType, false, PlayerContextConcurrencyMode.None));
                            })
                    };
                    _playMenuItems.Add(enqueueItem);
                }
                if (numAudio > 0)
                {
                    ListItem playItem_A = new ListItem(Consts.KEY_NAME, Consts.RES_PLAY_VIDEO_IMAGE_ITEMS_MUTED_CONCURRENT_AUDIO)
                    {
                        Command = new AsyncMethodDelegateCommand(() =>
                            {
                                LeaveCheckQueryPlayActionMultipleItemsState();
                                return(PlayOrEnqueueItems(getMediaItemsFunction, avType, true, PlayerContextConcurrencyMode.ConcurrentAudio));
                            })
                    };
                    _playMenuItems.Add(playItem_A);
                }
                if (numVideo > 0)
                {
                    ListItem playItem_V = new ListItem(Consts.KEY_NAME, Consts.RES_PLAY_VIDEO_IMAGE_ITEMS_PIP)
                    {
                        Command = new AsyncMethodDelegateCommand(() =>
                            {
                                LeaveCheckQueryPlayActionMultipleItemsState();
                                return(PlayOrEnqueueItems(getMediaItemsFunction, avType, true, PlayerContextConcurrencyMode.ConcurrentVideo));
                            })
                    };
                    _playMenuItems.Add(playItem_V);
                }
            }
            break;

            default:
            {
                IDialogManager dialogManager  = ServiceRegistration.Get <IDialogManager>();
                Guid           dialogHandleId = dialogManager.ShowDialog(Consts.RES_SYSTEM_INFORMATION, Consts.RES_CANNOT_PLAY_ITEMS_DIALOG_TEXT,
                                                                         DialogType.OkDialog, false, DialogButtonType.Ok);
                _dialogCloseWatcher = new DialogCloseWatcher(this, dialogHandleId, dialogResult => LeaveCheckQueryPlayActionMultipleItemsState());
            }
            break;
            }
            IScreenManager screenManager = ServiceRegistration.Get <IScreenManager>();

            screenManager.ShowDialog(Consts.DIALOG_PLAY_MENU, (dialogName, dialogInstanceId) => LeaveCheckQueryPlayActionMultipleItemsState());
        }
 /// <summary>
 /// Discards any current player and plays the media items of type <paramref name="avType"/> returned by the given
 /// <paramref name="getMediaItemsFunction"/>.
 /// </summary>
 /// <param name="getMediaItemsFunction">Function returning the media items to be played.</param>
 /// <param name="avType">AV type of media items returned.</param>
 public static async Task PlayItems(GetMediaItemsDlgt getMediaItemsFunction, AVType avType)
 {
     CloseSecondaryPlayerContext();
     await PlayOrEnqueueItems(getMediaItemsFunction, avType, true, PlayerContextConcurrencyMode.None);
 }
Beispiel #17
0
 /// <summary>
 /// Depending on parameter <paramref name="play"/>, plays or enqueues the media items of type <paramref name="avType"/>
 /// returned by the given <paramref name="getMediaItemsFunction"/>.
 /// This method can also be called from other models.
 /// </summary>
 /// <param name="getMediaItemsFunction">Function returning the media items to be played.</param>
 /// <param name="avType">AV type of media items to be played.</param>
 /// <param name="play">If <c>true</c>, plays the specified items, else enqueues it.</param>
 /// <param name="concurrencyMode">Determines if the media item will be played or enqueued in concurrency mode.</param>
 public static void PlayOrEnqueueItems(GetMediaItemsDlgt getMediaItemsFunction, AVType avType,
     bool play, PlayerContextConcurrencyMode concurrencyMode)
 {
   IWorkflowManager workflowManager = ServiceRegistration.Get<IWorkflowManager>();
   workflowManager.NavigatePush(Consts.WF_STATE_ID_PLAY_OR_ENQUEUE_ITEMS, new NavigationContextConfig
     {
         AdditionalContextVariables = new Dictionary<string, object>
           {
               {KEY_GET_MEDIA_ITEMS_FUNCTION, getMediaItemsFunction},
               {KEY_AV_TYPE, avType},
               {KEY_DO_PLAY, play},
               {KEY_CONCURRENCY_MODE, concurrencyMode},
           }
     });
 }
Beispiel #18
0
 protected void CheckPlayMenuInternal(GetMediaItemsDlgt getMediaItemsFunction, AVType avType)
 {
   IPlayerContextManager pcm = ServiceRegistration.Get<IPlayerContextManager>();
   int numOpen = pcm.NumActivePlayerContexts;
   if (numOpen == 0)
   {
     // Asynchronously leave the current workflow state because we're called from a workflow model method
     IThreadPool threadPool = ServiceRegistration.Get<IThreadPool>();
     threadPool.Add(() =>
       {
         LeaveCheckQueryPlayActionMultipleItemsState();
         PlayItems(getMediaItemsFunction, avType);
       });
     return;
   }
   _playMenuItems = new ItemsList();
   int numAudio = pcm.GetPlayerContextsByAVType(AVType.Audio).Count();
   int numVideo = pcm.GetPlayerContextsByAVType(AVType.Video).Count();
   switch (avType)
   {
     case AVType.Audio:
       {
         ListItem playItem = new ListItem(Consts.KEY_NAME, Consts.RES_PLAY_AUDIO_ITEMS)
           {
               Command = new MethodDelegateCommand(() =>
                 {
                   LeaveCheckQueryPlayActionMultipleItemsState();
                   PlayItems(getMediaItemsFunction, avType);
                 })
           };
         _playMenuItems.Add(playItem);
         if (numAudio > 0)
         {
           ListItem enqueueItem = new ListItem(Consts.KEY_NAME, Consts.RES_ENQUEUE_AUDIO_ITEMS)
             {
                 Command = new MethodDelegateCommand(() =>
                   {
                     LeaveCheckQueryPlayActionMultipleItemsState();
                     PlayOrEnqueueItems(getMediaItemsFunction, avType, false, PlayerContextConcurrencyMode.None);
                   })
             };
           _playMenuItems.Add(enqueueItem);
         }
         if (numVideo > 0)
         {
           ListItem playItemConcurrently = new ListItem(Consts.KEY_NAME, Consts.RES_MUTE_VIDEO_PLAY_AUDIO_ITEMS)
             {
                 Command = new MethodDelegateCommand(() =>
                   {
                     LeaveCheckQueryPlayActionMultipleItemsState();
                     PlayOrEnqueueItems(getMediaItemsFunction, avType, true, PlayerContextConcurrencyMode.ConcurrentVideo);
                   })
             };
           _playMenuItems.Add(playItemConcurrently);
         }
       }
       break;
     case AVType.Video:
       {
         ListItem playItem = new ListItem(Consts.KEY_NAME, Consts.RES_PLAY_VIDEO_IMAGE_ITEMS)
           {
               Command = new MethodDelegateCommand(() =>
                 {
                   LeaveCheckQueryPlayActionMultipleItemsState();
                   PlayItems(getMediaItemsFunction, avType);
                 })
           };
         _playMenuItems.Add(playItem);
         if (numVideo > 0)
         {
           ListItem enqueueItem = new ListItem(Consts.KEY_NAME, Consts.RES_ENQUEUE_VIDEO_IMAGE_ITEMS)
             {
                 Command = new MethodDelegateCommand(() =>
                   {
                     LeaveCheckQueryPlayActionMultipleItemsState();
                     PlayOrEnqueueItems(getMediaItemsFunction, avType, false, PlayerContextConcurrencyMode.None);
                   })
             };
           _playMenuItems.Add(enqueueItem);
         }
         if (numAudio > 0)
         {
           ListItem playItem_A = new ListItem(Consts.KEY_NAME, Consts.RES_PLAY_VIDEO_IMAGE_ITEMS_MUTED_CONCURRENT_AUDIO)
             {
                 Command = new MethodDelegateCommand(() =>
                   {
                     LeaveCheckQueryPlayActionMultipleItemsState();
                     PlayOrEnqueueItems(getMediaItemsFunction, avType, true, PlayerContextConcurrencyMode.ConcurrentAudio);
                   })
             };
           _playMenuItems.Add(playItem_A);
         }
         if (numVideo > 0)
         {
           ListItem playItem_V = new ListItem(Consts.KEY_NAME, Consts.RES_PLAY_VIDEO_IMAGE_ITEMS_PIP)
             {
                 Command = new MethodDelegateCommand(() =>
                   {
                     LeaveCheckQueryPlayActionMultipleItemsState();
                     PlayOrEnqueueItems(getMediaItemsFunction, avType, true, PlayerContextConcurrencyMode.ConcurrentVideo);
                   })
             };
           _playMenuItems.Add(playItem_V);
         }
       }
       break;
     default:
       {
         IDialogManager dialogManager = ServiceRegistration.Get<IDialogManager>();
         Guid dialogHandleId = dialogManager.ShowDialog(Consts.RES_SYSTEM_INFORMATION, Consts.RES_CANNOT_PLAY_ITEMS_DIALOG_TEXT,
             DialogType.OkDialog, false, DialogButtonType.Ok);
         _dialogCloseWatcher = new DialogCloseWatcher(this, dialogHandleId, dialogResult => LeaveCheckQueryPlayActionMultipleItemsState());
       }
       break;
   }
   IScreenManager screenManager = ServiceRegistration.Get<IScreenManager>();
   screenManager.ShowDialog(Consts.DIALOG_PLAY_MENU, (dialogName, dialogInstanceId) =>
       LeaveCheckQueryPlayActionMultipleItemsState());
 }
Beispiel #19
0
 protected void AsyncAddToPlaylist(IPlayerContext pc, GetMediaItemsDlgt getMediaItemsFunction, bool play)
 {
   IScreenManager screenManager = ServiceRegistration.Get<IScreenManager>();
   Guid? dialogInstanceId = screenManager.ShowDialog(Consts.DIALOG_ADD_TO_PLAYLIST_PROGRESS,
       (dialogName, instanceId) => StopAddToPlaylist());
   try
   {
     int numItems = 0;
     _stopAddToPlaylist = false;
     SetNumItemsAddedToPlaylist(0);
     ICollection<MediaItem> items = new List<MediaItem>();
     foreach (MediaItem item in getMediaItemsFunction())
     {
       SetNumItemsAddedToPlaylist(++numItems);
       if (_stopAddToPlaylist)
         break;
       items.Add(item);
     }
     pc.Playlist.AddAll(items);
   }
   finally
   {
     if (dialogInstanceId.HasValue)
       screenManager.CloseDialog(dialogInstanceId.Value);
     IWorkflowManager workflowManager = ServiceRegistration.Get<IWorkflowManager>();
     workflowManager.NavigatePopToState(Consts.WF_STATE_ID_PLAY_OR_ENQUEUE_ITEMS, true);
   }
   // Must be done after the dialog is closed
   CompletePlayOrEnqueue(pc, play);
 }
Beispiel #20
0
 /// <summary>
 /// First shows a menu to choose which media type should be played (Video, Audio, Image), then
 /// filters the items returned from the given <paramref name="getMediaItemsFunction"/>, checks if we need to show a
 /// menu for playing those items and shows that menu or adds all items to the playlist at once, starting playing,
 /// if no player is active and thus no menu needs to be shown.
 /// </summary>
 /// <param name="getMediaItemsFunction">Function which returns the media items to be added to the playlist. This function
 /// might take some time to return the items; in that case, a progress dialog will be shown.</param>
 public static void CheckQueryPlayAction(GetMediaItemsDlgt getMediaItemsFunction)
 {
   IWorkflowManager workflowManager = ServiceRegistration.Get<IWorkflowManager>();
   workflowManager.NavigatePush(Consts.WF_STATE_ID_QUERY_AV_TYPE_CHECK_QUERY_PLAYACTION_MULTIPLE_ITEMS, new NavigationContextConfig
     {
         AdditionalContextVariables = new Dictionary<string, object>
           {
               {KEY_GET_MEDIA_ITEMS_FUNCTION, getMediaItemsFunction},
           }
     });
 }
Beispiel #21
0
 protected void CheckQueryPlayAction_ShowMediaTypeChoice(GetMediaItemsDlgt getMediaItemsFunction)
 {
   _mediaTypeChoiceMenuItems = new ItemsList
     {
         new ListItem(Consts.KEY_NAME, Consts.RES_ADD_ALL_AUDIO)
           {
               Command = new MethodDelegateCommand(() => CheckQueryPlayAction_Continue(
                   getMediaItemsFunction, new Guid[] {AudioAspect.Metadata.AspectId}, AVType.Audio))
           },
         new ListItem(Consts.KEY_NAME, Consts.RES_ADD_ALL_VIDEOS)
           {
               Command = new MethodDelegateCommand(() => CheckQueryPlayAction_Continue(
                   getMediaItemsFunction, new Guid[] {VideoAspect.Metadata.AspectId}, AVType.Video))
           },
         new ListItem(Consts.KEY_NAME, Consts.RES_ADD_ALL_IMAGES)
           {
               Command = new MethodDelegateCommand(() => CheckQueryPlayAction_Continue(
                   getMediaItemsFunction, new Guid[] {ImageAspect.Metadata.AspectId}, AVType.Video))
           },
         new ListItem(Consts.KEY_NAME, Consts.RES_ADD_VIDEOS_AND_IMAGES)
           {
               Command = new MethodDelegateCommand(() => CheckQueryPlayAction_Continue(
                   getMediaItemsFunction, new Guid[] {VideoAspect.Metadata.AspectId, ImageAspect.Metadata.AspectId}, AVType.Video))
           },
     };
   IScreenManager screenManager = ServiceRegistration.Get<IScreenManager>();
   screenManager.ShowDialog(Consts.DIALOG_CHOOSE_AV_TYPE, (dialogName, dialogInstanceId) => LeaveQueryAVTypeState());
 }
Beispiel #22
0
 protected void CheckQueryPlayAction_Continue(GetMediaItemsDlgt getMediaItemsFunction,
     ICollection<Guid> consideredMediaItemAspectTypes, AVType avType)
 {
   LeaveQueryAVTypeState();
   CheckQueryPlayAction(() => FilterMediaItems(getMediaItemsFunction, consideredMediaItemAspectTypes), avType);
 }
Beispiel #23
0
 protected IEnumerable<MediaItem> FilterMediaItems(GetMediaItemsDlgt getMediaItemsFunction,
     ICollection<Guid> consideredMediaItemAspectTypes)
 {
   return getMediaItemsFunction().Where(mediaItem => consideredMediaItemAspectTypes.Any(aspectType => mediaItem.Aspects.ContainsKey(aspectType)));
 }
Beispiel #24
0
    protected void PlayOrEnqueueItemsInternal(GetMediaItemsDlgt getMediaItemsFunction, AVType avType,
        bool play, PlayerContextConcurrencyMode concurrencyMode)
    {
      IPlayerContext pc = PreparePlayerContext(avType, play, concurrencyMode);
      if (pc == null)
        return;

      // Adding items to playlist must be executed asynchronously - we will show a progress dialog where we aren't allowed
      // to block the input thread.
      IThreadPool threadPool = ServiceRegistration.Get<IThreadPool>();
      threadPool.Add(() => AsyncAddToPlaylist(pc, getMediaItemsFunction, play));
    }