// ウィンドウがアクティブになったタイミングで // キャッシュフォルダ―が格納されたストレージをホットスタンバイ状態にしたい // (コールドスタンバイ状態だと再生開始までのラグが大きい) 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(); } }
public override async Task OnNavigatedToAsync(INavigationParameters parameters) { await RefreshCacheSaveFolderStatus(); if (IsRequireUpdateCacheSaveFolder.Value) { NotificationService.ShowInAppNotification( InAppNotificationPayload.CreateReadOnlyNotification("ChoiceCacheSavingFolder".Translate(), showDuration: TimeSpan.FromSeconds(30) )); if (await CacheSaveFolder.ChangeUserDataFolder()) { await Task.Delay(1000); await RefreshCacheSaveFolderStatus(); await ResetList(); NotificationService.ShowInAppNotification( InAppNotificationPayload.CreateReadOnlyNotification("ReadyForVideoCache".Translate()) ); } } await base.OnNavigatedToAsync(parameters); }
protected override async Task NavigatedToAsync(CancellationToken cancelToken, NavigatedToEventArgs e, Dictionary <string, object> viewModelState) { await RefreshCacheSaveFolderStatus(); if (IsRequireUpdateCacheSaveFolder.Value) { NotificationService.ShowInAppNotification( InAppNotificationPayload.CreateReadOnlyNotification("キャッシュの保存先フォルダを選択してください。\n保存先が選択されると利用準備が完了します。", showDuration: TimeSpan.FromSeconds(30) )); if (await CacheSaveFolder.ChangeUserDataFolder()) { await Task.Delay(1000); await RefreshCacheSaveFolderStatus(); await ResetList(); NotificationService.ShowInAppNotification( InAppNotificationPayload.CreateReadOnlyNotification("キャッシュの利用準備が出来ました") ); } } await base.NavigatedToAsync(cancelToken, e, viewModelState); }
public override async Task OnNavigatedToAsync(INavigationParameters parameters) { await RefreshCacheSaveFolderStatus(); if (IsRequireUpdateCacheSaveFolder.Value) { NotificationService.ShowInAppNotification( InAppNotificationPayload.CreateReadOnlyNotification("キャッシュの保存先フォルダを選択してください。\n保存先が選択されると利用準備が完了します。", showDuration: TimeSpan.FromSeconds(30) )); if (await CacheSaveFolder.ChangeUserDataFolder()) { await Task.Delay(1000); await RefreshCacheSaveFolderStatus(); await ResetList(); NotificationService.ShowInAppNotification( InAppNotificationPayload.CreateReadOnlyNotification("キャッシュの利用準備が出来ました") ); } } await base.OnNavigatedToAsync(parameters); }
public VideoCacheIntroductionPageViewModel( CacheSettings cacheSettings, CacheSaveFolder cacheSaveFolder, DialogService dialogService ) { CacheSettings = cacheSettings; CacheSaveFolder = cacheSaveFolder; HohoemaDialogService = dialogService; var hasCacheFolder = Windows.Storage.AccessCache.StorageApplicationPermissions. FutureAccessList.Entries.Count > 0; IsCompleteCacheSettings = new ReactiveProperty <bool>(CacheSettings.IsUserAcceptedCache && hasCacheFolder) .AddTo(_Disposables); CanChangeCacheSettings = new ReactiveProperty <bool>(!IsCompleteCacheSettings.Value) .AddTo(_Disposables); RequireEnablingCacheCommand = CanChangeCacheSettings.ToAsyncReactiveCommand() .AddTo(_Disposables); RequireEnablingCacheCommand.Subscribe(async() => { bool isAcceptedCache = CacheSettings.IsUserAcceptedCache; if (!isAcceptedCache) { isAcceptedCache = await HohoemaDialogService.ShowAcceptCacheUsaseDialogAsync(); if (isAcceptedCache) { CacheSettings.IsEnableCache = true; CacheSettings.IsUserAcceptedCache = true; (App.Current).Resources["IsCacheEnabled"] = true; } } if (isAcceptedCache) { if (await CacheSaveFolder.ChangeUserDataFolder()) { IsCompleteCacheSettings.Value = true; } } }) .AddTo(_Disposables); }
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 ; }
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 ; }
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(); } }); }