Exemplo n.º 1
0
        protected void CheckPlayMenuInternal(MediaItem item)
        {
            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(() =>
                {
                    LeaveCheckQueryPlayActionSingleItemState();
                    PlayItem(item);
                });
                return;
            }
            _playMenuItems = new ItemsList();
            AVType avType   = pcm.GetTypeOfMediaItem(item);
            int    numAudio = pcm.NumPlayerContextsOfType(AVType.Audio);
            int    numVideo = pcm.NumPlayerContextsOfType(AVType.Video);

            switch (avType)
            {
            case AVType.Audio:
            {
                ListItem playItem = new ListItem(Consts.KEY_NAME, Consts.RES_PLAY_AUDIO_ITEM)
                {
                    Command = new MethodDelegateCommand(() =>
                        {
                            LeaveCheckQueryPlayActionSingleItemState();
                            PlayItem(item);
                        })
                };
                _playMenuItems.Add(playItem);
                if (numAudio > 0)
                {
                    ListItem enqueueItem = new ListItem(Consts.KEY_NAME, Consts.RES_ENQUEUE_AUDIO_ITEM)
                    {
                        Command = new MethodDelegateCommand(() =>
                            {
                                LeaveCheckQueryPlayActionSingleItemState();
                                PlayOrEnqueueItem(item, false, PlayerContextConcurrencyMode.None);
                            })
                    };
                    _playMenuItems.Add(enqueueItem);
                }
                if (numVideo > 0)
                {
                    ListItem playItemConcurrently = new ListItem(Consts.KEY_NAME, Consts.RES_MUTE_VIDEO_PLAY_AUDIO_ITEM)
                    {
                        Command = new MethodDelegateCommand(() =>
                            {
                                LeaveCheckQueryPlayActionSingleItemState();
                                PlayOrEnqueueItem(item, true, PlayerContextConcurrencyMode.ConcurrentVideo);
                            })
                    };
                    _playMenuItems.Add(playItemConcurrently);
                }
            }
            break;

            case AVType.Video:
            {
                ListItem playItem = new ListItem(Consts.KEY_NAME, Consts.RES_PLAY_VIDEO_IMAGE_ITEM)
                {
                    Command = new MethodDelegateCommand(() =>
                        {
                            LeaveCheckQueryPlayActionSingleItemState();
                            PlayItem(item);
                        })
                };
                _playMenuItems.Add(playItem);
                if (numVideo > 0)
                {
                    ListItem enqueueItem = new ListItem(Consts.KEY_NAME, Consts.RES_ENQUEUE_VIDEO_IMAGE_ITEM)
                    {
                        Command = new MethodDelegateCommand(() =>
                            {
                                LeaveCheckQueryPlayActionSingleItemState();
                                PlayOrEnqueueItem(item, false, PlayerContextConcurrencyMode.None);
                            })
                    };
                    _playMenuItems.Add(enqueueItem);
                }
                if (numAudio > 0)
                {
                    ListItem playItem_A = new ListItem(Consts.KEY_NAME, Consts.RES_PLAY_VIDEO_IMAGE_ITEM_MUTED_CONCURRENT_AUDIO)
                    {
                        Command = new MethodDelegateCommand(() =>
                            {
                                LeaveCheckQueryPlayActionSingleItemState();
                                PlayOrEnqueueItem(item, true, PlayerContextConcurrencyMode.ConcurrentAudio);
                            })
                    };
                    _playMenuItems.Add(playItem_A);
                }
                if (numVideo > 0)
                {
                    ListItem playItem_V = new ListItem(Consts.KEY_NAME, Consts.RES_PLAY_VIDEO_IMAGE_ITEM_PIP)
                    {
                        Command = new MethodDelegateCommand(() =>
                            {
                                LeaveCheckQueryPlayActionSingleItemState();
                                PlayOrEnqueueItem(item, 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_ITEM_DIALOG_TEXT,
                                                                         DialogType.OkDialog, false, DialogButtonType.Ok);
                _dialogCloseWatcher = new DialogCloseWatcher(this, dialogHandleId, dialogResult => LeaveCheckQueryPlayActionSingleItemState());
            }
            break;
            }
            IScreenManager screenManager = ServiceRegistration.Get <IScreenManager>();

            screenManager.ShowDialog(Consts.DIALOG_PLAY_MENU, (dialogName, dialogInstanceId) =>
                                     LeaveCheckQueryPlayActionSingleItemState());
        }