void Navigation(PageNavigationEventArgs args) { var pageType = args.PageType; var parameter = args.Paramter; var behavior = args.Behavior; Scheduler.Schedule(async() => { var isMainView = CoreApplication.GetCurrentView().IsMain; if (!args.IsMainViewTarget || !isMainView) { return; } using (var releaser = await _NavigationLock.LockAsync()) { // メインウィンドウでウィンドウ全体で再生している場合は // 強制的に小窓モードに切り替えてページを表示する if (!PlayerViewManager.IsPlayerSmallWindowModeEnabled && PlayerViewManager.IsPlayingWithPrimaryView) { PlayerViewManager.IsPlayerSmallWindowModeEnabled = true; } PageNavigating = true; try { var prefix = behavior == NavigationStackBehavior.Root ? "/" : String.Empty; var result = await NavigationService.NavigateAsync($"{prefix}{pageType.ToString()}Page", parameter); if (result.Success) { PageTitle = PageTitle ?? PageTypeToTitle(pageType); if (behavior == NavigationStackBehavior.NotRemember /*|| IsIgnoreRecordPageType(oldPageType)*/) { ForgetLastPage(); } } Debug.WriteLineIf(!result.Success, result.Exception?.ToString()); } finally { PageNavigating = false; } _ = PlayerViewManager.ShowMainView(); } }); }
public PageManager( INavigationService ns, IScheduler scheduler, IEventAggregator eventAggregator, AppearanceSettings appearanceSettings, CacheSettings cacheSettings, HohoemaPlaylist playlist, PlayerViewManager playerViewManager, DialogService dialogService ) { NavigationService = ns; Scheduler = scheduler; EventAggregator = eventAggregator; AppearanceSettings = appearanceSettings; CacheSettings = cacheSettings; HohoemaPlaylist = playlist; PlayerViewManager = playerViewManager; HohoemaDialogService = dialogService; EventAggregator.GetEvent <PageNavigationEvenet>() .Subscribe(args => { Navigation(args); } , ThreadOption.UIThread); SystemNavigationManager.GetForCurrentView().BackRequested += (_, e) => { if (PlayerViewManager.IsMainView) { // ウィンドウ全体で再生している場合 → バックキーで小窓表示へ移行 // それ以外の場合 → ページのバック処理 if (PlayerViewManager.IsPlayingWithPrimaryView && !PlayerViewManager.IsPlayerSmallWindowModeEnabled) { //PlayerViewManager.IsPlayerSmallWindowModeEnabled = true; e.Handled = true; } else if (NavigationService.CanGoBack()) { _ = NavigationService.GoBackAsync(); e.Handled = true; } } }; }
// Windows10のメディアコントロールとHohoemaのプレイリスト機能を統合してサポート // 外部からの次送り、前送り // プレイリストリセットなどに対応する // // 外部からの操作はイベントに切り出す // 画面の遷移自体はPageManagerに任せることにする // PageManagerに動画情報を渡すまでをやる // TODO: 「あとで見る」プレイリストをローミングフォルダへ書き出す public HohoemaPlaylist( IScheduler scheduler, NiconicoSession niconicoSession, VideoCacheManager videoCacheManager, PlaylistSettings playlistSettings, PlayerViewManager viewMan ) { Scheduler = scheduler; NiconicoSession = niconicoSession; VideoCacheManager = videoCacheManager; PlaylistSettings = playlistSettings; PlayerViewManager = viewMan; Player = new PlaylistPlayer(this, playlistSettings); MakeDefaultPlaylist(); Player.PlayRequested += Player_PlayRequested; // 一般会員は再生とキャッシュDLを1ラインしか許容していないため // 再生終了時にキャッシュダウンロードの再開を行う必要がある // PlayerViewManager.NowPlaying はSecondaryViewでの再生時にFalseを示してしまうため // IsPlayerShowWithSecondaryViewを使ってセカンダリビューでの再生中を検出している _resumingObserver = new[] { // PlayerViewManager.ObserveProperty(x => x.NowPlaying).Select(x => !x), PlayerViewManager.ObserveProperty(x => x.IsPlayerShowWithPrimaryView).Select(x => !x), PlayerViewManager.ObserveProperty(x => x.IsPlayerShowWithSecondaryView).Select(x => !x), NiconicoSession.ObserveProperty(x => x.IsPremiumAccount).Select(x => !x) } .CombineLatestValuesAreAllTrue() .Throttle(TimeSpan.FromSeconds(1)) .Subscribe(nowResumingCacheDL => { Scheduler.Schedule(() => { if (nowResumingCacheDL) { _ = VideoCacheManager.ResumeCacheDownload(); // TODO: キャッシュDL再開した場合の通知 } }); }); }
public PageManager( INavigationService ns, IScheduler scheduler, IEventAggregator eventAggregator, AppearanceSettings appearanceSettings, CacheSettings cacheSettings, HohoemaPlaylist playlist, PlayerViewManager playerViewManager, DialogService dialogService ) { NavigationService = ns; Scheduler = scheduler; EventAggregator = eventAggregator; AppearanceSettings = appearanceSettings; CacheSettings = cacheSettings; HohoemaPlaylist = playlist; PlayerViewManager = playerViewManager; HohoemaDialogService = dialogService; CurrentPageType = HohoemaPageType.RankingCategoryList; EventAggregator.GetEvent <PageNavigationEvenet>() .Subscribe(args => { var isMainView = ApplicationView.GetForCurrentView().Id == MainViewId; if (args.IsMainViewTarget && isMainView) { Navigation(args); } if (!args.IsMainViewTarget && !isMainView) { Navigation(args); } } , ThreadOption.UIThread); }
void Navigation(PageNavigationEventArgs args) { var pageType = args.PageType; var parameter = args.Paramter; var isForgetNavigation = args.IsForgetNavigation; Scheduler.Schedule(async() => { using (var releaser = await _NavigationLock.LockAsync()) { // メインウィンドウでウィンドウ全体で再生している場合は // 強制的に小窓モードに切り替えてページを表示する if (!PlayerViewManager.IsPlayerSmallWindowModeEnabled && PlayerViewManager.IsPlayingWithPrimaryView) { PlayerViewManager.IsPlayerSmallWindowModeEnabled = true; } PageNavigating = true; try { if (CurrentPageType == pageType && PageNavigationParameter == parameter) { return; } await Task.Delay(30); var oldPageTitle = PageTitle; PageTitle = ""; var oldPageType = CurrentPageType; CurrentPageType = pageType; var oldPageParameter = PageNavigationParameter; PageNavigationParameter = parameter; await Task.Delay(30); if (!NavigationService.Navigate(pageType.ToString(), parameter)) { CurrentPageType = oldPageType; PageTitle = oldPageTitle; PageNavigationParameter = oldPageParameter; } else { if (isForgetNavigation || IsIgnoreRecordPageType(oldPageType)) { ForgetLastPage(); } } } finally { PageNavigating = false; } _ = PlayerViewManager.ShowMainView(); } }); }