Beispiel #1
0
        private bool ShowPlayer(PlaylistItem item)
        {
            string pageType  = null;
            string parameter = null;

            switch (item.Type)
            {
            case PlaylistItemType.Video:
                pageType  = nameof(Views.VideoPlayerPage);
                parameter = new VideoPlayPayload()
                {
                    VideoId = item.ContentId
                }
                .ToParameterString();
                break;

            case PlaylistItemType.Live:
                pageType  = nameof(Views.LivePlayerPage);
                parameter = new LiveVideoPagePayload(item.ContentId)
                {
                    LiveTitle = item.Title,
                }
                .ToParameterString();
                break;

            default:
                break;
            }

            return(NavigationService.Navigate(pageType, parameter));
        }
Beispiel #2
0
        private bool ShowPlayer(PlaylistItem item)
        {
            string pageType  = null;
            string parameter = null;

            switch (item.Type)
            {
            case PlaylistItemType.Video:
                pageType  = nameof(Views.VideoPlayerPage);
                parameter = new VideoPlayPayload()
                {
                    VideoId = item.ContentId
                }
                .ToParameterString();
                break;

            case PlaylistItemType.Live:
                pageType  = nameof(Views.LivePlayerPage);
                parameter = new LiveVideoPagePayload(item.ContentId)
                {
                    LiveTitle = item.Title,
                }
                .ToParameterString();
                break;

            default:
                break;
            }

            if (NavigationService.Navigate(pageType, parameter))
            {
                ApplicationView currentView = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView();
                if (Helpers.DeviceTypeHelper.IsMobile)
                {
                    currentView.TryEnterFullScreenMode();
                }
                else if (Helpers.DeviceTypeHelper.IsDesktop && !HohoemaApp.Playlist.IsPlayerFloatingModeEnable)
                {
                    //
                    if (currentView.AdjacentToLeftDisplayEdge && currentView.AdjacentToRightDisplayEdge)
                    {
                        currentView.TryEnterFullScreenMode();
                    }
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #3
0
        private void HohoemaPlaylist_OpenPlaylistItem(IPlayableList playlist, PlaylistItem item)
        {
            // TODO: 別ウィンドウでプレイヤーを表示している場合に処理をキャンセル
            ClosePlayer();

            ViewModelBase newPlayerVM = null;
            string        parameter   = null;

            switch (item.Type)
            {
            case PlaylistItemType.Video:
                newPlayerVM = App.Current.Container.Resolve <VideoPlayerControlViewModel>();
                parameter   = new VideoPlayPayload()
                {
                    VideoId = item.ContentId
                }
                .ToParameterString();
                break;

            case PlaylistItemType.Live:
                newPlayerVM = App.Current.Container.Resolve <LiveVideoPlayerControlViewModel>();
                parameter   = new LiveVideoPagePayload(item.ContentId)
                {
                    LiveTitle = item.Title,
                }
                .ToParameterString();
                break;

            default:
                break;
            }

            if (newPlayerVM != null)
            {
                newPlayerVM.OnNavigatedTo(
                    new Prism.Windows.Navigation.NavigatedToEventArgs()
                {
                    NavigationMode = NavigationMode.New,
                    Parameter      = parameter
                }, viewModelState);

                ContentVM.Value = newPlayerVM;
            }
        }
Beispiel #4
0
        public override void OnNavigatedTo(NavigatedToEventArgs e, Dictionary <string, object> viewModelState)
        {
            if (e.Parameter is string)
            {
                var json    = e.Parameter as string;
                var payload = LiveVideoPagePayload.FromParameterString(json);

                LiveId        = payload.LiveId;
                LiveTitle     = payload.LiveTitle;
                CommunityId   = payload.CommunityId;
                CommunityName = payload.CommunityName;
            }

            if (LiveId != null)
            {
                NicoLiveVideo = new NicoLiveVideo(LiveId, HohoemaApp);

                NowConnecting = Observable.CombineLatest(
                    NicoLiveVideo.ObserveProperty(x => x.LiveStatusType).Select(x => x != null)
                    )
                                .Select(x => x.All(y => y))
                                .ToReactiveProperty(PlayerWindowUIDispatcherScheduler)
                                .AddTo(_NavigatingCompositeDisposable);
                OnPropertyChanged(nameof(NowConnecting));

                LiveComments = NicoLiveVideo.LiveComments.ToReadOnlyReactiveCollection(x =>
                {
                    var comment = new Views.Comment();

                    comment.CommentText    = x.Text;
                    comment.CommentId      = !string.IsNullOrEmpty(x.No) ? x.GetCommentNo() : 0;
                    comment.IsAnonimity    = !string.IsNullOrEmpty(x.Anonymity) ? x.GetAnonymity() : false;
                    comment.UserId         = x.User_id;
                    comment.IsOwnerComment = x.User_id == NicoLiveVideo?.BroadcasterId;

                    try
                    {
                        comment.IsLoginUserComment = !comment.IsAnonimity ? uint.Parse(x.User_id) == HohoemaApp.LoginUserId : false;
                    }
                    catch { }



                    //x.GetVposでサーバー上のコメント位置が取れるが、
                    // 受け取った順で表示したいのでローカルの放送時間からコメント位置を割り当てる
                    comment.VideoPosition = (uint)(MediaPlayer.PlaybackSession.Position.TotalMilliseconds * 0.1) + 50;

                    if (x.Vpos != null && x.GetVpos() < (comment.VideoPosition - 200))
                    {
                        Debug.WriteLine("古いコメントのため非表示 : " + comment.CommentText);
                        comment.IsVisible = false;
                    }

                    // EndPositionはコメントレンダラが再計算するが、仮置きしないと表示対象として処理されない
                    comment.EndPosition = comment.VideoPosition + 1000;

                    comment.ApplyCommands(x.GetCommandTypes());

                    return(comment);
                });

                OnPropertyChanged(nameof(LiveComments));

                CommentCount = NicoLiveVideo.ObserveProperty(x => x.CommentCount)
                               .ToReactiveProperty(PlayerWindowUIDispatcherScheduler)
                               .AddTo(_NavigatingCompositeDisposable);
                OnPropertyChanged(nameof(CommentCount));

                WatchCount = NicoLiveVideo.ObserveProperty(x => x.WatchCount)
                             .ToReactiveProperty(PlayerWindowUIDispatcherScheduler)
                             .AddTo(_NavigatingCompositeDisposable);
                OnPropertyChanged(nameof(WatchCount));

                CommunityId = NicoLiveVideo.BroadcasterCommunityId;


                // post comment
                NicoLiveVideo.PostCommentResult += NicoLiveVideo_PostCommentResult;

                // operation command
                PermanentDisplayText = NicoLiveVideo.ObserveProperty(x => x.PermanentDisplayText)
                                       .ToReactiveProperty(PlayerWindowUIDispatcherScheduler)
                                       .AddTo(_NavigatingCompositeDisposable);
                OnPropertyChanged(nameof(PermanentDisplayText));


                // next live
                NicoLiveVideo.NextLive += NicoLiveVideo_NextLive;
            }

            base.OnNavigatedTo(e, viewModelState);
        }