/// <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;
                        }
                    });
                }
            }
        }
Beispiel #2
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;
            }
        }
        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;
            }
        }