private async void PartGridView_ItemClick(object sender, ItemClickEventArgs e) { var item = e.ClickedItem as VideoPart; if (item.cid != _currentPartId) { _currentPartId = item.cid; await MyVideoPlayer.Init(_detail, _currentPartId); } }
public async Task Init(VideoDetail detail, int partId = 0) { Reset(); App.AppViewModel.CurrentPlayerType = Models.Enums.PlayerType.Video; App.AppViewModel.CurrentVideoPlayer = VideoPlayer; _detail = detail; _currentPartId = partId; TabletMainPage.Current.SetBackgroundImage(_detail.pic); if (!string.IsNullOrEmpty(_detail.redirect_url)) { var result = BiliTool.GetResultFromUri(_detail.redirect_url); videoId = 0; _currentPartId = 0; if (result.Type == UriType.Bangumi) { throw new InvalidDataException(result.Param); } } TitleBlock.Text = detail.title; ToolTipService.SetToolTip(TitleBlock, _detail.title); videoId = _detail.aid; bvId = _detail.bvid; PlayCountBlock.Text = AppTool.GetNumberAbbreviation(_detail.stat.view); DanmakuCountBlock.Text = AppTool.GetNumberAbbreviation(_detail.stat.danmaku); RepostButton.Text = AppTool.GetNumberAbbreviation(_detail.stat.share); CommentButton.Text = AppTool.GetNumberAbbreviation(_detail.stat.reply); BVBlock.Text = _detail.bvid; AVBlock.Text = _detail.aid.ToString(); DescriptionBlock.Text = _detail.desc; LikeButton.Text = AppTool.GetNumberAbbreviation(_detail.stat.like); CoinButton.Text = AppTool.GetNumberAbbreviation(_detail.stat.coin); FavoriteButton.Text = AppTool.GetNumberAbbreviation(_detail.stat.favorite); PublishBlock.Text = AppTool.GetReadDateString(_detail.pubdate); UPAvatar.ProfilePicture = string.IsNullOrEmpty(_detail.owner.face) ? null : new BitmapImage(new Uri(_detail.owner.face + "@50w.jpg")) { DecodePixelWidth = 40 }; UPNameBlock.Text = _detail.owner.name; if (_detail.pages != null) { _detail.pages.ForEach(p => VideoPartCollection.Add(p)); PartGridView.SelectedIndex = 0; } PartContainer.Visibility = _detail.pages.Count > 1 ? Visibility.Visible : Visibility.Collapsed; if (_detail.tag != null && _detail.tag.Count > 0) { TagGridView.Visibility = Visibility.Visible; _detail.tag.ForEach(p => TagCollection.Add(p)); } else { TagGridView.Visibility = Visibility.Collapsed; } if (_detail.staff != null && _detail.staff.Count > 0) { _detail.staff.ForEach(p => StaffCollection.Add(p)); SingleUserContainer.Visibility = Visibility.Collapsed; StaffContainer.Visibility = Visibility.Visible; } else { StaffContainer.Visibility = Visibility.Collapsed; SingleUserContainer.Visibility = Visibility.Visible; } if (_detail.req_user != null) { LikeButton.IsCheck = _detail.req_user.like != 0; CoinButton.IsCheck = _detail.req_user.coin != 0; FavoriteButton.IsCheck = _detail.req_user.favorite != 0; } await MyVideoPlayer.Init(_detail, _currentPartId); CheckLikeHoldState(); }