Example #1
0
 // ウィンドウがアクティブになったタイミングで
 // キャッシュフォルダ―が格納されたストレージをホットスタンバイ状態にしたい
 // (コールドスタンバイ状態だと再生開始までのラグが大きい)
 private async void Current_Activated(object sender, Windows.UI.Core.WindowActivatedEventArgs e)
 {
     if (e.WindowActivationState == Windows.UI.Core.CoreWindowActivationState.CodeActivated)
     {
         var folder = await CacheSaveFolder.GetVideoCacheFolder();
     }
 }
Example #2
0
        private async Task RefreshCacheSaveFolderStatus()
        {
            var cacheFolderAccessState = await CacheSaveFolder.GetVideoCacheFolderState();

            CacheSaveFolderPath.Value = "";
            switch (cacheFolderAccessState)
            {
            case CacheFolderAccessState.NotAccepted:
                CacheFolderStateDescription.Value = "CacheFolderAccessState.NotAccepted_Desc".Translate();
                break;

            case CacheFolderAccessState.NotEnabled:
                CacheFolderStateDescription.Value = "CacheFolderAccessState.NotEnabled_Desc".Translate();
                break;

            case CacheFolderAccessState.NotSelected:
                CacheFolderStateDescription.Value = "CacheFolderAccessState.NotSelected_Desc".Translate();
                break;

            case CacheFolderAccessState.SelectedButNotExist:
                CacheFolderStateDescription.Value = "CacheFolderAccessState.SelectedButNotExist_Desc".Translate();
                CacheSaveFolderPath.Value         = "?????";
                break;

            case CacheFolderAccessState.Exist:
                CacheFolderStateDescription.Value = "ReadyForVideoCache".Translate();
                break;

            default:
                break;
            }

            var folder = await CacheSaveFolder.GetVideoCacheFolder();

            if (folder != null)
            {
                CacheSaveFolderPath.Value = $"{folder.Path}";
            }


            IsRequireUpdateCacheSaveFolder.Value =
                cacheFolderAccessState == CacheFolderAccessState.SelectedButNotExist ||
                cacheFolderAccessState == CacheFolderAccessState.NotSelected
            ;
        }
Example #3
0
        private async Task RefreshCacheSaveFolderStatus()
        {
            var cacheFolderAccessState = await CacheSaveFolder.GetVideoCacheFolderState();

            CacheSaveFolderPath.Value = "";
            switch (cacheFolderAccessState)
            {
            case CacheFolderAccessState.NotAccepted:
                CacheFolderStateDescription.Value = "キャッシュ利用の同意が必要です。 「キャッシュを有効にする」ボタンを押すと同意文書が表示されます。";
                break;

            case CacheFolderAccessState.NotEnabled:
                CacheFolderStateDescription.Value = "キャッシュの有効化が必要です";
                break;

            case CacheFolderAccessState.NotSelected:
                CacheFolderStateDescription.Value = "フォルダを選択するとキャッシュ機能が使えるようになります";
                break;

            case CacheFolderAccessState.SelectedButNotExist:
                CacheFolderStateDescription.Value = "選択されたフォルダが確認できません。外付けストレージを再接続するか、キャッシュ先フォルダを再選択してください。";
                CacheSaveFolderPath.Value         = "?????";
                break;

            case CacheFolderAccessState.Exist:
                CacheFolderStateDescription.Value = "キャッシュ利用の準備ができました";
                break;

            default:
                break;
            }

            var folder = await CacheSaveFolder.GetVideoCacheFolder();

            if (folder != null)
            {
                CacheSaveFolderPath.Value = $"{folder.Path}";
            }


            IsRequireUpdateCacheSaveFolder.Value =
                cacheFolderAccessState == CacheFolderAccessState.SelectedButNotExist ||
                cacheFolderAccessState == CacheFolderAccessState.NotSelected
            ;
        }
Example #4
0
        public CacheManagementPageViewModel(
            ApplicationLayoutManager applicationLayoutManager,
            CacheSettings cacheSettings,
            VideoCacheManager videoCacheManager,
            CacheSaveFolder cacheSaveFolder,
            NicoVideoProvider nicoVideoProvider,
            PageManager pageManager,
            DialogService dialogService,
            NotificationService notificationService,
            HohoemaPlaylist hohoemaPlaylist
            )
        {
            ApplicationLayoutManager       = applicationLayoutManager;
            CacheSettings                  = cacheSettings;
            VideoCacheManager              = videoCacheManager;
            CacheSaveFolder                = cacheSaveFolder;
            NicoVideoProvider              = nicoVideoProvider;
            HohoemaDialogService           = dialogService;
            NotificationService            = notificationService;
            HohoemaPlaylist                = hohoemaPlaylist;
            IsRequireUpdateCacheSaveFolder = new ReactiveProperty <bool>(false);

            IsCacheUserAccepted = CacheSettings.ObserveProperty(x => x.IsUserAcceptedCache)
                                  .ToReadOnlyReactiveProperty();

            RequireEnablingCacheCommand = new DelegateCommand(async() =>
            {
                var result = await HohoemaDialogService.ShowAcceptCacheUsaseDialogAsync();
                if (result)
                {
                    CacheSettings.IsEnableCache               = true;
                    CacheSettings.IsUserAcceptedCache         = true;
                    (App.Current).Resources["IsCacheEnabled"] = true;

                    await RefreshCacheSaveFolderStatus();

                    NotificationService.ShowInAppNotification(
                        InAppNotificationPayload.CreateReadOnlyNotification("ChoiceCacheSavingFolder".Translate(),
                                                                            showDuration: TimeSpan.FromSeconds(30)
                                                                            ));

                    if (await CacheSaveFolder.ChangeUserDataFolder())
                    {
                        await RefreshCacheSaveFolderStatus();

                        await VideoCacheManager.CacheFolderChanged();

                        await ResetList();

                        NotificationService.ShowInAppNotification(
                            InAppNotificationPayload.CreateReadOnlyNotification("ReadyForVideoCache".Translate())
                            );
                    }
                }
            });

            ReadCacheAcceptTextCommand = new DelegateCommand(async() =>
            {
                var result = await HohoemaDialogService.ShowAcceptCacheUsaseDialogAsync(showWithoutConfirmButton: true);
            });



            CacheFolderStateDescription = new ReactiveProperty <string>("");
            CacheSaveFolderPath         = new ReactiveProperty <string>("");

            OpenCurrentCacheFolderCommand = new DelegateCommand(async() =>
            {
                await RefreshCacheSaveFolderStatus();

                var folder = await CacheSaveFolder.GetVideoCacheFolder();
                if (folder != null)
                {
                    await Launcher.LaunchFolderAsync(folder);
                }
            });


            ChangeCacheFolderCommand = new DelegateCommand(async() =>
            {
                var prevPath = CacheSaveFolderPath.Value;

                if (await CacheSaveFolder.ChangeUserDataFolder())
                {
                    NotificationService.ShowInAppNotification(
                        InAppNotificationPayload.CreateReadOnlyNotification("CacheSaveFolderChangeToX".Translate(CacheSaveFolderPath.Value))
                        );

                    await RefreshCacheSaveFolderStatus();

                    await VideoCacheManager.CacheFolderChanged();

                    await ResetList();
                }
            });
        }