public void HandleUri(string url, string title = "") { var result = BiliTool.GetResultFromUri(url); if (result.Type.ToString().Contains("Video")) { if (result.Type == UriType.VideoA) { PlayVideo(Convert.ToInt32(result.Param)); } else { var args = new VideoActiveArgs() { bvid = result.Param }; PlayVideo(args); } } else if (result.Type == UriType.Bangumi) { PlayBangumi(Convert.ToInt32(result.Param), null, true); } else if (result.Type == UriType.Document) { ShowDoucmentPopup(title, Convert.ToInt32(result.Param)); } else if (result.Type == UriType.Web) { ShowWebPopup(title, result.Param); } }
private void MainContentControl_Tapped(object sender, TappedRoutedEventArgs e) { if (_cardType == "video") { var data = Data as VideoDynamic; object ele = EnableConnectAnimation ? sender : null; if (string.IsNullOrEmpty(data.redirect_url)) { App.AppViewModel.PlayVideo(data.aid, ele, StaticString.SIGN_DYNAMIC); } else { var result = BiliTool.GetResultFromUri(data.redirect_url); if (result.Type == BiliBili_Lib.Enums.UriType.Bangumi) { App.AppViewModel.PlayBangumi(Convert.ToInt32(result.Param), ele, true); } } } else if (_cardType == "web") { var item = Data as WebDynamic; App.AppViewModel.ShowWebPopup(item.sketch.title, item.sketch.target_url); } else if (_cardType == "anime") { var item = Data as AnimeDynamic; App.AppViewModel.PlayBangumi(item.episode_id, sender, true); } else if (_cardType == "document") { DocumentTapped?.Invoke(this, EventArgs.Empty); } else if (_cardType == "live") { var item = Data as LiveDynamic; App.AppViewModel.ShowWebPopup(item.title, $"https://live.bilibili.com/{item.roomid}"); } else if (_cardType == "music") { var item = Data as MusicDynamic; App.AppViewModel.ShowWebPopup(item.title, $"https://www.bilibili.com/audio/au{item.id}?type=7"); } }
private async Task InitVideo(int aid, int cid, string bvid) { if (!Container.Children.Contains(_videoBlock)) { Container.Children.Add(_videoBlock); } _videoBlock.Visibility = Visibility.Visible; try { await _videoBlock.Init(aid, cid, bvid); } catch (InvalidDataException) { Container.Children.Remove(_videoBlock); _videoBlock.Visibility = Visibility.Collapsed; var result = BiliTool.GetResultFromUri(_videoBlock._detail.redirect_url); await InitBangumi(Convert.ToInt32(result.Param), true); } }
private void VideoListView_ItemClick(object sender, ItemClickEventArgs e) { var data = e.ClickedItem as ArchiveVideo; if (data.@goto == "av") { var ana = BiliTool.GetResultFromUri(data.uri); if (ana.Type == BiliBili_Lib.Enums.UriType.Bangumi) { App.AppViewModel.PlayBangumi(Convert.ToInt32(ana.Param), null, true); } else { App.AppViewModel.PlayVideo(Convert.ToInt32(data.param)); } } else if (data.@goto == "bangumi") { App.AppViewModel.PlayBangumi(Convert.ToInt32(data.param), null, true); } }
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(); }
private bool InitDetail() { if (!string.IsNullOrEmpty(_detail.redirect_url)) { var result = BiliTool.GetResultFromUri(_detail.redirect_url); videoId = 0; _currentPartId = 0; App.AppViewModel.CurrentPagePanel.RemoveMainHistory(Models.Enums.AppMenuItemType.VideoPlayer); if (result.Type == UriType.Bangumi) { new TipPopup("正在转到专题...").ShowMessage(); App.AppViewModel.PlayBangumi(Convert.ToInt32(result.Param), null, true); } return(false); } if (_isPlayList) { VideoPlayer.IsAutoReturnWhenEnd = false; } else { VideoPlayer.IsAutoReturnWhenEnd = _detail.pages.Count <= 1; } TitleBlock.Text = _detail.title; ToolTipService.SetToolTip(TitleBlock, _detail.title); videoId = _detail.aid; bvId = _detail.bvid; PlayCountBlock.Text = AppTool.GetNumberAbbreviation(_detail.stat.view); DanmukuCountBlock.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); DateBlock.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; _detail.pages.ForEach(p => VideoPartCollection.Add(p)); PartListView.SelectedIndex = PartGridView.SelectedIndex = 0; PartContainer.Visibility = _detail.pages.Count > 1 ? Visibility.Visible : Visibility.Collapsed; if (_detail.tag != null && _detail.tag.Count > 0) { TagListView.Visibility = Visibility.Visible; _detail.tag.ForEach(p => TagCollection.Add(p)); } else { TagListView.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; FollowButton.Style = _detail.req_user.attention == 1 ? UIHelper.GetStyle("DefaultAsyncButtonStyle") : UIHelper.GetStyle("PrimaryAsyncButtonStyle"); FollowButton.Text = _detail.req_user.attention == 1 ? "已关注" : "关注"; } if (_detail.relates != null && _detail.relates.Count > 0) { _detail.relates.Where(p => p.@goto == "av").Take(10).ToList().ForEach(p => RelatedCollection.Add(p)); } CheckLikeHoldState(); return(true); }