コード例 #1
0
 /// <summary>
 /// Removes removable media items that are no longer availabale
 /// </summary>
 /// <param name="mediaItems"></param>
 public static void RemoveRemovableMediaItems(IEnumerable <MediaItem> mediaItems)
 {
     foreach (var item in mediaItems)
     {
         RemovableMediaItems.TryRemove(item.MediaItemId, out _);
     }
 }
コード例 #2
0
 /// <summary>
 /// Adds removabale media items, so they can stand in for stubs while available
 /// </summary>
 /// <param name="mediaItems"></param>
 public static void AddOrUpdateRemovableMediaItems(IEnumerable <MediaItem> mediaItems)
 {
     foreach (var item in mediaItems)
     {
         RemovableMediaItems.AddOrUpdate(item.MediaItemId, item, (g, i) => item);
     }
 }
コード例 #3
0
        protected async Task CheckResumeMenuInternal(MediaItem item, int edition)
        {
            // Use actual removable media item if present for stub
            if (item.IsStub && RemovableMediaItems.TryGetValue(item.MediaItemId, out var removableItem))
            {
                item = removableItem;
            }

            // First make sure the correct edition is selected
            if (edition <= item.MaximumEditionIndex)
            {
                item.ActiveEditionIndex = edition;
            }

            IResumeState    resumeState = null;
            IUserManagement userProfileDataManagement = ServiceRegistration.Get <IUserManagement>();

            if (userProfileDataManagement.IsValidUser)
            {
                var userResult = await userProfileDataManagement.UserProfileDataManagement.GetUserMediaItemDataAsync(userProfileDataManagement.CurrentUser.ProfileId, item.MediaItemId, PlayerContext.KEY_RESUME_STATE);

                if (userResult.Success)
                {
                    resumeState = ResumeStateBase.Deserialize(userResult.Result);
                }
            }

            // Check if resume state matches the current edition, if not start from beginning
            IResumeStateEdition rse = resumeState as IResumeStateEdition;

            if (rse != null && rse.ActiveEditionIndex != edition)
            {
                resumeState = null;
            }

            if (item.IsStub || resumeState == null)
            {
                // Asynchronously leave the current workflow state because we're called from a workflow model method
                //await Task.Yield();
                await Task.Run(async() =>
                {
                    LeaveCheckResumePlaybackSingleItemState();
                    await PlayItem(item);
                });

                return;
            }
            _playMenuItems = new ItemsList();
            ListItem resumeItem = new ListItem
            {
                Command = new AsyncMethodDelegateCommand(() =>
                {
                    LeaveCheckResumePlaybackSingleItemState();
                    return(PlayItem(item, resumeState));
                })
            };
            PositionResumeState positionResume = resumeState as PositionResumeState;

            if (positionResume != null)
            {
                string playbackResume = LocalizationHelper.Translate(Consts.RES_PLAYBACK_RESUME_TIME, positionResume.ResumePosition.ToString(@"hh\:mm\:ss"));
                resumeItem.SetLabel(Consts.KEY_NAME, playbackResume);
            }
            else
            {
                resumeItem.SetLabel(Consts.KEY_NAME, Consts.RES_PLAYBACK_RESUME);
            }
            _playMenuItems.Add(resumeItem);
            ListItem playItem = new ListItem(Consts.KEY_NAME, Consts.RES_PLAYBACK_FROMSTART)
            {
                Command = new AsyncMethodDelegateCommand(() =>
                {
                    LeaveCheckResumePlaybackSingleItemState();
                    return(PlayItem(item));
                })
            };

            _playMenuItems.Add(playItem);
            IScreenManager screenManager = ServiceRegistration.Get <IScreenManager>();

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