Ejemplo n.º 1
0
        public async Task NavigationAsync(string pageName, INavigationParameters parameters)
        {
            using (await _playerNavigationLock.LockAsync())
            {
                if (SecondaryCoreAppView == null)
                {
                    await CreateSecondaryView();
                }

                await SecondaryCoreAppView.ExecuteOnUIThreadAsync(async() =>
                {
                    var result = await SecondaryViewPlayerNavigationService.NavigateAsync(pageName, parameters, new DrillInNavigationTransitionInfo());
                    if (result.Success)
                    {
                        var name = ResolveContentName(pageName, parameters);
                        SecondaryAppView.Title = name != null ? $"{name}" : "Hohoema";
                    }
                    else
                    {
                        Debug.WriteLine(result.Exception?.ToString());
                        await CloseAsync();
                        throw result.Exception;
                    }

                    await ApplicationViewSwitcher.TryShowAsStandaloneAsync(this.SecondaryAppView.Id, ViewSizePreference.Default, MainViewId, ViewSizePreference.UseNone);
                });

//                await ShowSecondaryViewAsync();

                IsShowSecondaryView = true;
            }
        }
        public async Task NavigationAsync(string pageName, INavigationParameters parameters)
        {
            LastNavigatedPageName = pageName;
            using (await _playerNavigationLock.LockAsync())
            {
                if (SecondaryCoreAppView == null)
                {
                    await CreateSecondaryView();
                }

                await SecondaryCoreAppView.DispatcherQueue.EnqueueAsync(async() =>
                {
                    var result = await SecondaryViewPlayerNavigationService.NavigateAsync(pageName, parameters, _PlayerPageNavgationTransitionInfo);
                    if (!result.IsSuccess)
                    {
                        Debug.WriteLine(result.Exception?.ToString());
                        await CloseAsync();
                        throw result.Exception;
                    }

                    //Analytics.TrackEvent("PlayerNavigation", new Dictionary<string, string>
                    //{
                    //    { "PageType",  pageName },
                    //    { "ViewType", "Secondary" },
                    //    { "CompactOverlay", (SecondaryAppView.ViewMode == ApplicationViewMode.CompactOverlay).ToString() },
                    //    { "FullScreen", SecondaryAppView.IsFullScreenMode.ToString() },
                    //});
                });

                await ShowAsync();

                IsShowSecondaryView = true;
            }
        }
        private async void SecondaryAppView_Consolidated(ApplicationView sender, ApplicationViewConsolidatedEventArgs args)
        {
            Debug.WriteLine($"SecondaryAppView_Consolidated: IsAppInitiated:{args.IsAppInitiated} IsUserInitiated:{args.IsUserInitiated}");

            await PlaylistPlayer.ClearAsync();

            await SecondaryViewPlayerNavigationService.NavigateAsync(nameof(BlankPage), _BlankPageNavgationTransitionInfo);

            // Note: 1803時点での話
            // VisibleBoundsChanged がアプリ終了前に呼ばれるが
            // この際メインウィンドウとセカンダリウィンドウのウィンドウサイズが互い違いに送られてくるため
            // 直前のウィンドウサイズの値を前々回表示のウィンドウサイズ(_PrevSecondaryViewSize)で上書きする
            if (_PrevSecondaryViewSize != default(Size))
            {
                var localObjectStorageHelper = Microsoft.Toolkit.Mvvm.DependencyInjection.Ioc.Default.GetService <Microsoft.Toolkit.Uwp.Helpers.LocalObjectStorageHelper>();
                localObjectStorageHelper.Save(secondary_view_size, _PrevSecondaryViewSize);
            }

            _scheduler.Schedule(() =>
            {
                IsShowSecondaryView = false;
            });

            LastNavigatedPageName = null;

            // プレイヤーを閉じた時に再生中情報をクリア
            if (!isMainViewClosed)
            {
                Debug.WriteLine("ClearCurrentPlayerEntry secondary view closed.");
                _restoreNavigationManager.ClearCurrentPlayerEntry();
            }
        }
Ejemplo n.º 4
0
 private void Current_Suspending(object sender, Windows.ApplicationModel.SuspendingEventArgs e)
 {
     if (IsMainView)
     {
         PrimaryViewPlayerNavigationService.RemoveAllPages();
     }
     else
     {
         SecondaryViewPlayerNavigationService.RemoveAllPages();
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// SecondaryViewを閉じます。
        /// MainViewから呼び出すと別スレッドアクセスでエラーになるはず
        /// </summary>
        public async void ClosePlayer()
        {
            using (await NowPlayingLock.LockAsync())
            {
                if (IsMainView)
                {
                    PrimaryViewScheduler.Schedule(() =>
                    {
                        PrimaryViewPlayerNavigationService.NavigateAsync(nameof(Views.BlankPage), new SuppressNavigationTransitionInfo());

                        NowPlaying = false;
                        ToggleFullScreenWhenApplicationViewShowWithStandalone();
                    });
                }
                else
                {
                    SecondaryViewScheduler.Schedule(async() =>
                    {
                        await SecondaryViewPlayerNavigationService.NavigateAsync(nameof(Views.BlankPage), new SuppressNavigationTransitionInfo());

                        NowPlaying = false;
                        ToggleFullScreenWhenApplicationViewShowWithStandalone();

                        await ShowMainView();

                        if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 4))
                        {
                            await CurrentView.TryConsolidateAsync().AsTask()
                            .ContinueWith(prevTask =>
                            {
                                //                        CoreAppView = null;
                                //                        AppView = null;
                                //                        _SecondaryViewVM = null;
                                //                        NavigationService = null;
                            });
                        }
                        else
                        {
                            SecondaryCoreAppView = null;
                            SecondaryAppView     = null;
                            _SecondaryViewVM     = null;
                            SecondaryViewPlayerNavigationService = null;
                        }
                    });
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// SecondaryViewを閉じます。
        /// MainViewから呼び出すと別スレッドアクセスでエラーになるはず
        /// </summary>
        public async Task CloseAsync()
        {
            if (!IsShowSecondaryView)
            {
                return;
            }

            await SecondaryCoreAppView.ExecuteOnUIThreadAsync(async() =>
            {
                SecondaryAppView.Title = "Hohoema";

                await ShowMainViewAsync();

                await SecondaryViewPlayerNavigationService.NavigateAsync(nameof(Views.BlankPage), new SuppressNavigationTransitionInfo());

                await SecondaryAppView.TryConsolidateAsync();
            });
        }
Ejemplo n.º 7
0
        private async void SecondaryAppView_Consolidated(ApplicationView sender, ApplicationViewConsolidatedEventArgs args)
        {
            SecondaryViewPlayerNavigationService.Navigate(nameof(Views.BlankPage), null);

            // Note: 1803時点での話
            // VisibleBoundsChanged がアプリ終了前に呼ばれるが
            // この際メインウィンドウとセカンダリウィンドウのウィンドウサイズが互い違いに送られてくるため
            // 直前のウィンドウサイズの値を前々回表示のウィンドウサイズ(_PrevSecondaryViewSize)で上書きする
            if (_PrevSecondaryViewSize != default(Size))
            {
                var localObjectStorageHelper = App.Current.Container.Resolve <Microsoft.Toolkit.Uwp.Helpers.LocalObjectStorageHelper>();
                localObjectStorageHelper.Save(secondary_view_size, _PrevSecondaryViewSize);
            }

            // セカンダリウィンドウを閉じるタイミングでキャッシュを再開する
            // プレミアム会員の場合は何もおきない
            var cacheManager = App.Current.Container.Resolve <VideoCacheManager>();
            await cacheManager.ResumeCacheDownload();
        }
Ejemplo n.º 8
0
        private async void SecondaryAppView_Consolidated(ApplicationView sender, ApplicationViewConsolidatedEventArgs args)
        {
            await SecondaryViewPlayerNavigationService.NavigateAsync(nameof(Views.BlankPage), new SuppressNavigationTransitionInfo());

            // Note: 1803時点での話
            // VisibleBoundsChanged がアプリ終了前に呼ばれるが
            // この際メインウィンドウとセカンダリウィンドウのウィンドウサイズが互い違いに送られてくるため
            // 直前のウィンドウサイズの値を前々回表示のウィンドウサイズ(_PrevSecondaryViewSize)で上書きする
            if (_PrevSecondaryViewSize != default(Size))
            {
                var localObjectStorageHelper = App.Current.Container.Resolve <Microsoft.Toolkit.Uwp.Helpers.LocalObjectStorageHelper>();
                localObjectStorageHelper.Save(secondary_view_size, _PrevSecondaryViewSize);
            }

            _scheduler.Schedule(() =>
            {
                IsShowSecondaryView = false;
            });
        }
        /// <summary>
        /// SecondaryViewを閉じます。
        /// </summary>
        public async Task CloseAsync()
        {
            if (!IsShowSecondaryView)
            {
                return;
            }

            await SecondaryCoreAppView.DispatcherQueue.EnqueueAsync(async() =>
            {
                await PlaylistPlayer.ClearAsync();

                SecondaryAppView.Title = "Hohoema";

                await SecondaryViewPlayerNavigationService.NavigateAsync(nameof(BlankPage), _BlankPageNavgationTransitionInfo);

                await Task.Delay(250);

                await SecondaryAppView.TryConsolidateAsync();
            });

            await ShowMainViewAsync();
        }
Ejemplo n.º 10
0
        public async Task PlayWithCurrentPlayerView(PlaylistItem item)
        {
            using (await NowPlayingLock.LockAsync())
            {
                var    pageType  = item.Type == PlaylistItemType.Video ? nameof(Views.VideoPlayerPage) : nameof(Views.LivePlayerPage);
                string parameter = null;
                switch (item.Type)
                {
                case PlaylistItemType.Video:
                    parameter = new VideoPlayPayload()
                    {
                        VideoId = item.ContentId
                    }
                    .ToParameterString();

                    break;

                case PlaylistItemType.Live:
                    parameter = new Models.Live.LiveVideoPagePayload(item.ContentId)
                    {
                        LiveTitle = item.Title
                    }
                    .ToParameterString();

                    break;
                }

                if (parameter == null)
                {
                    throw new ArgumentException("PlayerViewManager failed player frame navigation");
                }

                if (PlayerViewMode == PlayerViewMode.PrimaryView)
                {
                    Debug.WriteLine("Play with Primary : " + parameter);

                    PrimaryViewScheduler.Schedule(() =>
                    {
                        PrimaryViewPlayerNavigationService.Navigate(pageType, parameter);
                        //                    _ = ApplicationViewSwitcher.TryShowAsStandaloneAsync(MainViewId);
                    });
                }

                if (PlayerViewMode == PlayerViewMode.SecondaryView)
                {
                    Debug.WriteLine("Play with Secondary : " + parameter);

                    // サブウィンドウをアクティベートして、サブウィンドウにPlayerページナビゲーションを飛ばす
                    await GetEnsureSecondaryView();

                    SecondaryViewScheduler.Schedule(() =>
                    {
                        if (SecondaryViewPlayerNavigationService.Navigate(pageType, parameter))
                        {
                            SecondaryAppView.Title = !string.IsNullOrEmpty(item?.Title) ? item.Title : "Hohoema";
                        }
                        else
                        {
                            SecondaryAppView.Title = "Hohoema!";
                        }
                    });
                }

                _CurrentPlayItem = item;
            }
        }
Ejemplo n.º 11
0
        public async Task PlayWithCurrentPlayerView(PlaylistItem item)
        {
            using (await NowPlayingLock.LockAsync())
            {
                var pageType = item.Type == PlaylistItemType.Video ? nameof(Views.VideoPlayerPage) : nameof(Views.LivePlayerPage);
                NavigationParameters parameter = new NavigationParameters();
                switch (item.Type)
                {
                case PlaylistItemType.Video:
                    parameter.Add("id", item.ContentId);

                    break;

                case PlaylistItemType.Live:
                    parameter.Add("id", item.ContentId);
                    parameter.Add("title", item.Title);

                    break;
                }

                if (parameter == null)
                {
                    throw new ArgumentException("PlayerViewManager failed player frame navigation");
                }

                if (PlayerViewMode == PlayerViewMode.PrimaryView)
                {
                    Debug.WriteLine("Play with Primary : " + parameter);

                    PrimaryViewScheduler.Schedule(async() =>
                    {
                        NowPlaying = true;
                        ToggleFullScreenWhenApplicationViewShowWithStandalone();

                        var result = await PrimaryViewPlayerNavigationService.NavigateAsync(pageType, parameter, new DrillInNavigationTransitionInfo());
                        if (!result.Success)
                        {
                            NowPlaying = false;
                            ToggleFullScreenWhenApplicationViewShowWithStandalone();
                        }

                        //                    _ = ApplicationViewSwitcher.TryShowAsStandaloneAsync(MainViewId);
                    });
                }

                if (PlayerViewMode == PlayerViewMode.SecondaryView)
                {
                    Debug.WriteLine("Play with Secondary : " + parameter);

                    // サブウィンドウをアクティベートして、サブウィンドウにPlayerページナビゲーションを飛ばす
                    await GetEnsureSecondaryView();

                    SecondaryViewScheduler.Schedule(async() =>
                    {
                        NowPlaying = true;
                        ToggleFullScreenWhenApplicationViewShowWithStandalone();

                        var result = await SecondaryViewPlayerNavigationService.NavigateAsync(pageType, parameter, new DrillInNavigationTransitionInfo());
                        if (result.Success)
                        {
                            SecondaryAppView.Title = !string.IsNullOrEmpty(item?.Title) ? item.Title : "Hohoema";
                        }
                        else
                        {
                            NowPlaying = false;
                            ToggleFullScreenWhenApplicationViewShowWithStandalone();

                            SecondaryAppView.Title = "Hohoema!";
                        }
                    });
                }

                _CurrentPlayItem = item;
            }
        }