/// <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); }
public IEnumerable <IPlayerContext> GetPlayerContextsByAVType(AVType avType) { lock (SyncObj) { return(GetPlayerContexts((pc, slotIndex) => pc.AVType == avType).OfType <IPlayerContext>()); } }
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); } }
internal PlayerContext(IPlayerSlotController slotController, Guid mediaModuleId, string name, AVType type, Guid currentlyPlayingWorkflowStateId, Guid fullscreenContentWorkflowStateId) { _slotController = slotController; _slotController.Closed += OnClosed; SetContextVariable(KEY_PLAYER_CONTEXT, this); _playlist = new Playlist(this); _mediaModuleId = mediaModuleId; _name = name; _type = type; _currentlyPlayingWorkflowStateId = currentlyPlayingWorkflowStateId; _fullscreenContentWorkflowStateId = fullscreenContentWorkflowStateId; }
internal PlayerContext(IPlayerSlotController slotController, Guid mediaModuleId, string name, AVType type, Guid currentlyPlayingWorkflowStateId, Guid fullscreenContentWorkflowStateId) { _slotController = slotController; _slotController.Closed += OnClosed; SetContextVariable(KEY_PLAYER_CONTEXT, this); _playlist = new Playlist(this); _mediaModuleId = mediaModuleId; _name = name; _type = type; _currentlyPlayingWorkflowStateId = currentlyPlayingWorkflowStateId; _fullscreenContentWorkflowStateId = fullscreenContentWorkflowStateId; }
public IEnumerable <IPlayerContext> GetPlayerContextsByAVType(AVType avType) { lock (SyncObj) { for (int i = 0; i < 2; i++) { IPlayerContext pc = GetPlayerContext(i); if (pc != null && pc.AVType == avType) { yield return(pc); } } } }
public int NumPlayerContextsOfType(AVType avType) { lock (SyncObj) { int result = 0; for (int i = 0; i < 2; i++) { IPlayerContext pc = GetPlayerContext(i); if (pc != null && pc.AVType == avType) { result++; } } return(result); } }
/// <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)); }
protected static bool GetPlayerContextNameForMediaType(AVType avType, out string contextName) { // No locking necessary if (avType == AVType.Video) { contextName = LocalizationHelper.Translate(Consts.RES_VIDEO_IMAGE_CONTEXT_NAME); return(true); } if (avType == AVType.Audio) { contextName = LocalizationHelper.Translate(Consts.RES_AUDIO_CONTEXT_NAME); return(true); } contextName = null; return(false); }
/// <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); }
protected static IPlayerContext PreparePlayerContext(AVType avType, bool play, PlayerContextConcurrencyMode concurrencyMode) { IPlayerContextManager pcm = ServiceRegistration.Get <IPlayerContextManager>(); string contextName; if (!GetPlayerContextNameForMediaType(avType, out contextName)) { return(null); } IPlayerContext pc = null; if (!play) { // !play means enqueue - so find our first player context of the correct media type IList <IPlayerContext> playerContexts = new List <IPlayerContext>( pcm.GetPlayerContextsByMediaModuleId(Consts.MODULE_ID_MEDIA).Where(playerContext => playerContext.AVType == avType)); // In case the media type is audio, we have max. one player context of that type. In case media type is // video, we might have two. But we handle enqueue only for the first video player context. pc = playerContexts.FirstOrDefault(); } if (pc == null) { // No player context to reuse - so open a new one if (avType == AVType.Video) { pc = pcm.OpenVideoPlayerContext(Consts.MODULE_ID_MEDIA, contextName, concurrencyMode, Consts.WF_STATE_ID_CURRENTLY_PLAYING_VIDEO, Consts.WF_STATE_ID_FULLSCREEN_VIDEO); } else if (avType == AVType.Audio) { pc = pcm.OpenAudioPlayerContext(Consts.MODULE_ID_MEDIA, contextName, concurrencyMode == PlayerContextConcurrencyMode.ConcurrentVideo, Consts.WF_STATE_ID_CURRENTLY_PLAYING_AUDIO, Consts.WF_STATE_ID_FULLSCREEN_AUDIO); } } if (pc == null) { return(null); } if (play) { pc.Playlist.Clear(); } return(pc); }
protected void CheckAutoPlay(string drive, AVType type) { if (string.IsNullOrEmpty(drive)) { return; } if (_removableMediaItems.TryGetValue(drive, out var items)) { if (type == AVType.None) { PlayItemsModel.CheckQueryPlayAction(() => items); } else { PlayItemsModel.CheckQueryPlayAction(() => items, type); } } }
/// <summary> /// Checks if we need to show a menu for playing all items provided by the given <paramref name="getMediaItemsFunction"/> /// 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> /// <param name="avType">AV type of media items to be played.</param> public static void CheckQueryPlayAction(GetMediaItemsDlgt getMediaItemsFunction, AVType avType) { IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>(); workflowManager.NavigatePush(Consts.WF_STATE_ID_CHECK_QUERY_PLAYACTION_MULTIPLE_ITEMS, new NavigationContextConfig { AdditionalContextVariables = new Dictionary <string, object> { { KEY_GET_MEDIA_ITEMS_FUNCTION, getMediaItemsFunction }, { KEY_AV_TYPE, avType }, } }); }
protected void UpdatePlaylistHeader(AVType? avType, bool isPrimary) { if (!avType.HasValue) { PlaylistHeader = null; return; } switch (avType.Value) { case AVType.Audio: PlaylistHeader = Consts.RES_AUDIO_PLAYLIST; break; case AVType.Video: PlaylistHeader = isPrimary ? Consts.RES_VIDEO_IMAGE_PLAYLIST : Consts.RES_PIP_PLAYLIST; break; default: // Unknown player context type PlaylistHeader = null; break; } }
public static string ConvertAVTypeToPlaylistType(AVType avType) { return avType.ToString(); }
protected static IPlayerContext PreparePlayerContext(AVType avType, bool play, PlayerContextConcurrencyMode concurrencyMode) { IPlayerContextManager pcm = ServiceRegistration.Get<IPlayerContextManager>(); string contextName; if (!GetPlayerContextNameForMediaType(avType, out contextName)) return null; IPlayerContext pc = null; if (!play) { // !play means enqueue - so find our first player context of the correct media type IList<IPlayerContext> playerContexts = new List<IPlayerContext>( pcm.GetPlayerContextsByMediaModuleId(Consts.MODULE_ID_MEDIA).Where(playerContext => playerContext.AVType == avType)); // In case the media type is audio, we have max. one player context of that type. In case media type is // video, we might have two. But we handle enqueue only for the first video player context. pc = playerContexts.FirstOrDefault(); } if (pc == null) // No player context to reuse - so open a new one if (avType == AVType.Video) pc = pcm.OpenVideoPlayerContext(Consts.MODULE_ID_MEDIA, contextName, concurrencyMode, Consts.WF_STATE_ID_CURRENTLY_PLAYING_VIDEO, Consts.WF_STATE_ID_FULLSCREEN_VIDEO); else if (avType == AVType.Audio) pc = pcm.OpenAudioPlayerContext(Consts.MODULE_ID_MEDIA, contextName, concurrencyMode == PlayerContextConcurrencyMode.ConcurrentVideo, Consts.WF_STATE_ID_CURRENTLY_PLAYING_AUDIO, Consts.WF_STATE_ID_FULLSCREEN_AUDIO); if (pc == null) return null; if (play) pc.Playlist.Clear(); return pc; }
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(); CheckEdition(item); //CheckResumeAction(item); }); return; } _playMenuItems = new ItemsList(); AVType avType = pcm.GetTypeOfMediaItem(item); 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_ITEM) { Command = new MethodDelegateCommand(() => { LeaveCheckQueryPlayActionSingleItemState(); CheckEdition(item); //CheckResumeAction(item); }) }; _playMenuItems.Add(playItem); if (numAudio > 0) { ListItem enqueueItem = new ListItem(Consts.KEY_NAME, Consts.RES_ENQUEUE_AUDIO_ITEM) { Command = new AsyncMethodDelegateCommand(() => { LeaveCheckQueryPlayActionSingleItemState(); return(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 AsyncMethodDelegateCommand(() => { LeaveCheckQueryPlayActionSingleItemState(); return(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(); CheckEdition(item); //CheckResumeAction(item); }) }; _playMenuItems.Add(playItem); if (numVideo > 0) { ListItem enqueueItem = new ListItem(Consts.KEY_NAME, Consts.RES_ENQUEUE_VIDEO_IMAGE_ITEM) { Command = new AsyncMethodDelegateCommand(() => { LeaveCheckQueryPlayActionSingleItemState(); return(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 AsyncMethodDelegateCommand(() => { LeaveCheckQueryPlayActionSingleItemState(); return(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 AsyncMethodDelegateCommand(() => { LeaveCheckQueryPlayActionSingleItemState(); return(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()); }
/// <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 Task 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 }, } }); return(Task.CompletedTask); }
/// <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 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); }); }
protected void CheckQueryPlayAction_Continue(GetMediaItemsDlgt getMediaItemsFunction, ICollection<Guid> consideredMediaItemAspectTypes, AVType avType) { LeaveQueryAVTypeState(); CheckQueryPlayAction(() => FilterMediaItems(getMediaItemsFunction, consideredMediaItemAspectTypes), avType); }
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)); }
protected static bool GetPlayerContextNameForMediaType(AVType avType, out string contextName) { // No locking necessary if (avType == AVType.Video) { contextName = LocalizationHelper.Translate(Consts.RES_VIDEO_IMAGE_CONTEXT_NAME); return true; } if (avType == AVType.Audio) { contextName = LocalizationHelper.Translate(Consts.RES_AUDIO_CONTEXT_NAME); return true; } contextName = null; return false; }
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()); }
/// <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); }
/// <summary> /// Checks if we need to show a menu for playing all items provided by the given <paramref name="getMediaItemsFunction"/> /// 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> /// <param name="avType">AV type of media items to be played.</param> public static void CheckQueryPlayAction(GetMediaItemsDlgt getMediaItemsFunction, AVType avType) { IWorkflowManager workflowManager = ServiceRegistration.Get<IWorkflowManager>(); workflowManager.NavigatePush(Consts.WF_STATE_ID_CHECK_QUERY_PLAYACTION_MULTIPLE_ITEMS, new NavigationContextConfig { AdditionalContextVariables = new Dictionary<string, object> { {KEY_GET_MEDIA_ITEMS_FUNCTION, getMediaItemsFunction}, {KEY_AV_TYPE, avType}, } }); }
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)); }
/// <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); }
public int NumPlayerContextsOfType(AVType avType) { lock (SyncObj) { int result = 0; for (int i = 0; i < 2; i++) { IPlayerContext pc = GetPlayerContext(i); if (pc != null && pc.AVType == avType) result++; } return result; } }
/// <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 void CheckQueryPlayAction_Continue(GetMediaItemsDlgt getMediaItemsFunction, ICollection <Guid> consideredMediaItemAspectTypes, AVType avType) { LeaveQueryAVTypeState(); CheckQueryPlayAction(() => FilterMediaItems(getMediaItemsFunction, consideredMediaItemAspectTypes), avType); }
public IEnumerable<IPlayerContext> GetPlayerContextsByAVType(AVType avType) { lock (SyncObj) { for (int i = 0; i < 2; i++) { IPlayerContext pc = GetPlayerContext(i); if (pc != null && pc.AVType == avType) yield return pc; } } }
public static string ConvertAVTypeToPlaylistType(AVType avType) { return(avType.ToString()); }
protected void UpdatePlaylistHeader(AVType? avType, int slotIndex) { if (!avType.HasValue) { PlaylistHeader = null; return; } switch (avType.Value) { case AVType.Audio: PlaylistHeader = Consts.RES_AUDIO_PLAYLIST; break; case AVType.Video: PlaylistHeader = slotIndex == PlayerManagerConsts.PRIMARY_SLOT ? Consts.RES_VIDEO_IMAGE_PLAYLIST : Consts.RES_PIP_PLAYLIST; break; default: // Unknown player context type PlaylistHeader = null; break; } }