diff --git a/src/BiliLite.UWP/BiliLite.UWP.csproj b/src/BiliLite.UWP/BiliLite.UWP.csproj index 3b629933..39eeff03 100644 --- a/src/BiliLite.UWP/BiliLite.UWP.csproj +++ b/src/BiliLite.UWP/BiliLite.UWP.csproj @@ -152,9 +152,13 @@ VideoListView.xaml + + EditPlaySpeedMenuDialog.xaml + SendDynamicV2Dialog.xaml + @@ -164,6 +168,7 @@ + @@ -174,9 +179,22 @@ + + + + + + + + + + + + + UserDynamicPage.xaml @@ -694,7 +712,7 @@ - + @@ -1005,6 +1023,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + MSBuild:Compile Designer diff --git a/src/BiliLite.UWP/Controls/DataTemplateSelectors/UserDynamicItemV2DataTemplateSelector.cs b/src/BiliLite.UWP/Controls/DataTemplateSelectors/UserDynamicItemV2DataTemplateSelector.cs index d3bd975d..6147bf51 100644 --- a/src/BiliLite.UWP/Controls/DataTemplateSelectors/UserDynamicItemV2DataTemplateSelector.cs +++ b/src/BiliLite.UWP/Controls/DataTemplateSelectors/UserDynamicItemV2DataTemplateSelector.cs @@ -13,9 +13,6 @@ public class UserDynamicItemV2DataTemplateSelector : DataTemplateSelector static UserDynamicItemV2DataTemplateSelector() { - DataTemplate SelectRowTemplate(UserDynamicItemDataTemplateSelector selector, - UserDynamicItemDisplayViewModel _) => selector.OneRowTemplate; - _dynamicTypeTemplateSelectFuncs = new Dictionary>() diff --git a/src/BiliLite.UWP/Controls/Dynamic/DynamicItemV2Control.xaml b/src/BiliLite.UWP/Controls/Dynamic/DynamicItemV2Control.xaml index d08645d6..2168b986 100644 --- a/src/BiliLite.UWP/Controls/Dynamic/DynamicItemV2Control.xaml +++ b/src/BiliLite.UWP/Controls/Dynamic/DynamicItemV2Control.xaml @@ -175,10 +175,12 @@ diff --git a/src/BiliLite.UWP/Controls/PlayerControl.xaml b/src/BiliLite.UWP/Controls/PlayerControl.xaml index 7c5ad501..fc2eae9b 100644 --- a/src/BiliLite.UWP/Controls/PlayerControl.xaml +++ b/src/BiliLite.UWP/Controls/PlayerControl.xaml @@ -12,6 +12,7 @@ xmlns:canvas="using:Microsoft.Graphics.Canvas.UI.Xaml" xmlns:fa="using:FontAwesome5" xmlns:player="using:BiliLite.Modules.Player" xmlns:common="using:BiliLite.Models.Common" + xmlns:player1="using:BiliLite.Models.Common.Player" d:DesignHeight="800" d:DesignWidth="1000"> @@ -845,15 +846,20 @@ - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/src/BiliLite.UWP/Dialogs/EditPlaySpeedMenuDialog.xaml.cs b/src/BiliLite.UWP/Dialogs/EditPlaySpeedMenuDialog.xaml.cs new file mode 100644 index 00000000..c093c778 --- /dev/null +++ b/src/BiliLite.UWP/Dialogs/EditPlaySpeedMenuDialog.xaml.cs @@ -0,0 +1,46 @@ +using System.Collections.ObjectModel; +using System.Linq; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Input; +using BiliLite.Models.Common.Player; +using BiliLite.Services; +using BiliLite.ViewModels.Settings; + +// https://go.microsoft.com/fwlink/?LinkId=234238 上介绍了“内容对话框”项模板 + +namespace BiliLite.Dialogs +{ + public sealed partial class EditPlaySpeedMenuDialog : ContentDialog + { + private readonly EditPlaySpeedMenuViewModel m_viewModel; + private readonly PlaySpeedMenuService m_playSpeedMenuService; + + public EditPlaySpeedMenuDialog(EditPlaySpeedMenuViewModel viewModel, PlaySpeedMenuService playSpeedMenuService) + { + m_viewModel = viewModel; + m_playSpeedMenuService = playSpeedMenuService; + m_viewModel.PlaySpeedMenuItems = new ObservableCollection(m_playSpeedMenuService.MenuItems); + this.InitializeComponent(); + } + + private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) + { + m_playSpeedMenuService.SetMenuItems(m_viewModel.PlaySpeedMenuItems.ToList()); + } + + private void BtnRemovePlaySpeed_OnTapped(object sender, TappedRoutedEventArgs e) + { + if (!(sender is Button btn)) return; + if (!(btn.DataContext is PlaySpeedMenuItem menuItem)) return; + + m_viewModel.PlaySpeedMenuItems.Remove(menuItem); + } + + private void BtnAddPlaySpeed_OnTapped(object sender, TappedRoutedEventArgs e) + { + m_viewModel.PlaySpeedMenuItems.Add(new PlaySpeedMenuItem(m_viewModel.AddPlaySpeedValue)); + m_viewModel.PlaySpeedMenuItems = + new ObservableCollection(m_viewModel.PlaySpeedMenuItems.OrderByDescending(x => x.Value)); + } + } +} diff --git a/src/BiliLite.UWP/Extensions/BizServicesExtensions.cs b/src/BiliLite.UWP/Extensions/BizServicesExtensions.cs new file mode 100644 index 00000000..fa0c23b6 --- /dev/null +++ b/src/BiliLite.UWP/Extensions/BizServicesExtensions.cs @@ -0,0 +1,14 @@ +using BiliLite.Services.Biz; +using Microsoft.Extensions.DependencyInjection; + +namespace BiliLite.Extensions +{ + public static class BizServicesExtensions + { + public static IServiceCollection AddBizServices(this IServiceCollection services) + { + services.AddTransient(); + return services; + } + } +} diff --git a/src/BiliLite.UWP/Extensions/ControlsExtensions.cs b/src/BiliLite.UWP/Extensions/ControlsExtensions.cs index 85b954d5..34f7629d 100644 --- a/src/BiliLite.UWP/Extensions/ControlsExtensions.cs +++ b/src/BiliLite.UWP/Extensions/ControlsExtensions.cs @@ -10,6 +10,7 @@ public static IServiceCollection AddControls(this IServiceCollection services) { services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); return services; diff --git a/src/BiliLite.UWP/Extensions/MapperExtensions.cs b/src/BiliLite.UWP/Extensions/MapperExtensions.cs index 96f5be43..f3d90e76 100644 --- a/src/BiliLite.UWP/Extensions/MapperExtensions.cs +++ b/src/BiliLite.UWP/Extensions/MapperExtensions.cs @@ -66,6 +66,10 @@ public static IServiceCollection AddMapper(this IServiceCollection services) expression.CreateMap(); expression.CreateMap(); expression.CreateMap(); + expression.CreateMap() + .ForMember(dest => dest.Author, + opt => opt.MapFrom(src => + src.Upper.Name)); var danmakuModeConvertDic = new Dictionary() { diff --git a/src/BiliLite.UWP/Extensions/StringExtensions.cs b/src/BiliLite.UWP/Extensions/StringExtensions.cs index 104ce35e..50635e1f 100644 --- a/src/BiliLite.UWP/Extensions/StringExtensions.cs +++ b/src/BiliLite.UWP/Extensions/StringExtensions.cs @@ -461,7 +461,7 @@ private static string HandelVideoID(string input) offset = 0; foreach (Match item in bv) { - if (keyword.Contains(item.Groups[0].Value) || haveHandledOffset.Where(index => (item.Index > index[0] && item.Index < index[1])).ToList().Count > 0) + if (keyword.Contains(item.Groups[0].Value) || haveHandledOffset.Where(index => (item.Index + offset > index[0] && item.Index + offset < index[1])).ToList().Count > 0) { continue; } @@ -482,7 +482,7 @@ private static string HandelVideoID(string input) MatchCollection av = Regex.Matches(input, @"[aA][vV](\d+)"); foreach (Match item in av) { - if (keyword.Contains(item.Groups[0].Value) || haveHandledOffset.Where(index => (item.Index > index[0] && item.Index < index[1])).ToList().Count > 0) + if (keyword.Contains(item.Groups[0].Value) || haveHandledOffset.Where(index => (item.Index + offset > index[0] && item.Index + offset < index[1])).ToList().Count > 0 || item.Groups[1].Value.ToInt64() < 2) { continue; } diff --git a/src/BiliLite.UWP/Extensions/ViewModelExtensions.cs b/src/BiliLite.UWP/Extensions/ViewModelExtensions.cs index f0492021..fa42c78e 100644 --- a/src/BiliLite.UWP/Extensions/ViewModelExtensions.cs +++ b/src/BiliLite.UWP/Extensions/ViewModelExtensions.cs @@ -3,6 +3,8 @@ using BiliLite.ViewModels.Download; using BiliLite.ViewModels.Home; using BiliLite.ViewModels.Live; +using BiliLite.ViewModels.Rank; +using BiliLite.ViewModels.Settings; using BiliLite.ViewModels.User; using BiliLite.ViewModels.User.SendDynamic; using BiliLite.ViewModels.UserDynamic; @@ -40,6 +42,8 @@ public static IServiceCollection AddViewModels(this IServiceCollection services) services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); return services; } } diff --git a/src/BiliLite.UWP/Models/Common/Enumerates.cs b/src/BiliLite.UWP/Models/Common/Enumerates.cs index 7c1be225..76916e36 100644 --- a/src/BiliLite.UWP/Models/Common/Enumerates.cs +++ b/src/BiliLite.UWP/Models/Common/Enumerates.cs @@ -471,4 +471,23 @@ public enum UserCaptainType /// JianZhang = 3, } + + /// + /// 排行榜分区类型 + /// + public enum RankRegionType + { + /// + /// 全部 + /// + All, + /// + /// 原创 + /// + Origin, + /// + /// 新人 + /// + Rookie + } } \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Player/PlaySpeedMenu.cs b/src/BiliLite.UWP/Models/Common/Player/PlaySpeedMenu.cs new file mode 100644 index 00000000..bad6e73f --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Player/PlaySpeedMenu.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BiliLite.Models.Common.Player +{ + public class PlaySpeedMenuItem + { + public PlaySpeedMenuItem(){} + + public PlaySpeedMenuItem(double value) + { + Value = value; + } + + public string Content => Value + "x"; + + public double Value { get; set; } + } +} diff --git a/src/BiliLite.UWP/Models/Common/Rank/RankItemModel.cs b/src/BiliLite.UWP/Models/Common/Rank/RankItemModel.cs new file mode 100644 index 00000000..528cc696 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Rank/RankItemModel.cs @@ -0,0 +1,48 @@ +using Newtonsoft.Json; + +namespace BiliLite.Models.Common.Rank +{ + public class RankItemModel + { + public int Rank { get; set; } + + public string Aid { get; set; } + + public int Videos { get; set; } + + public int Tid { get; set; } + + public string Tname { get; set; } + + public int Copyright { get; set; } + + public string Pic { get; set; } + + public string Title { get; set; } + + public int Pubdate { get; set; } + + public int Ctime { get; set; } + + public string Desc { get; set; } + + public int State { get; set; } + + public int Duration { get; set; } + + [JsonProperty("mission_id")] + public int MissionId { get; set; } + + public RankItemOwnerModel Owner { get; set; } + + public RankItemStatModel Stat { get; set; } + + public string Dynamic { get; set; } + + public long Cid { get; set; } + + public string Bvid { get; set; } + + public int Score { get; set; } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Rank/RankItemOwnerModel.cs b/src/BiliLite.UWP/Models/Common/Rank/RankItemOwnerModel.cs new file mode 100644 index 00000000..e4a5c672 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Rank/RankItemOwnerModel.cs @@ -0,0 +1,11 @@ +namespace BiliLite.Models.Common.Rank +{ + public class RankItemOwnerModel + { + public long Mid { get; set; } + + public string Name { get; set; } + + public string Face { get; set; } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Rank/RankItemStatModel.cs b/src/BiliLite.UWP/Models/Common/Rank/RankItemStatModel.cs new file mode 100644 index 00000000..ddc6d601 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Rank/RankItemStatModel.cs @@ -0,0 +1,19 @@ +namespace BiliLite.Models.Common.Rank +{ + public class RankItemStatModel + { + public long Aid { get; set; } + + public long View { get; set; } + + public long Danmaku { get; set; } + + public long Reply { get; set; } + + public long Favorite { get; set; } + + public long Coin { get; set; } + + public long Share { get; set; } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/SettingConstants.cs b/src/BiliLite.UWP/Models/Common/SettingConstants.cs index 9b5a4bdd..6128a677 100644 --- a/src/BiliLite.UWP/Models/Common/SettingConstants.cs +++ b/src/BiliLite.UWP/Models/Common/SettingConstants.cs @@ -773,6 +773,9 @@ public class Player [SettingDefaultValue] public const bool DEFAULT_REPORT_HISTORY_ZERO_WHEN_VIDEO_END = false; + + [SettingKey(typeof(string))] + public const string PLAY_SPEED_MENU = "PlaySpeedMenu"; } public class Roaming diff --git a/src/BiliLite.UWP/Models/Common/Video/MediaListResources.cs b/src/BiliLite.UWP/Models/Common/Video/MediaListResources.cs new file mode 100644 index 00000000..5ca129b6 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Video/MediaListResources.cs @@ -0,0 +1,33 @@ +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace BiliLite.Models.Common.Video +{ + public class MediaListResources + { + [JsonProperty("media_list")] + public List MediaList { get; set; } + + [JsonProperty("has_more")] + public bool HasMore { get; set; } + + [JsonProperty("total_count")] + public int TotalCount { get; set; } + } + + public class MediaListItem + { + public long Id { get; set; } + + public string Title { get; set; } + + public string Cover { get; set; } + + public MediaListItemUpper Upper { get; set; } + } + + public class MediaListItemUpper + { + public string Name { get; set; } + } +} diff --git a/src/BiliLite.UWP/Models/Common/Video/VideoListSection.cs b/src/BiliLite.UWP/Models/Common/Video/VideoListSection.cs index 46909573..a357f104 100644 --- a/src/BiliLite.UWP/Models/Common/Video/VideoListSection.cs +++ b/src/BiliLite.UWP/Models/Common/Video/VideoListSection.cs @@ -13,5 +13,9 @@ public class VideoListSection public List Items { get; set; } public VideoListItem SelectedItem { get; set; } + + public bool IsLazyOnlineList { get; set; } + + public string OnlineListId { get; set; } } } \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Video/VideoPlaylist.cs b/src/BiliLite.UWP/Models/Common/Video/VideoPlaylist.cs index 107722bf..c9bb0d45 100644 --- a/src/BiliLite.UWP/Models/Common/Video/VideoPlaylist.cs +++ b/src/BiliLite.UWP/Models/Common/Video/VideoPlaylist.cs @@ -9,5 +9,9 @@ public class VideoPlaylist public List Playlist { get; set; } public string Title { get; set; } + + public bool IsOnlineMediaList { get; set; } + + public string MediaListId { get; set; } } } \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Functions/AddVolumeFunction.cs b/src/BiliLite.UWP/Models/Functions/AddVolumeFunction.cs new file mode 100644 index 00000000..a1b373ec --- /dev/null +++ b/src/BiliLite.UWP/Models/Functions/AddVolumeFunction.cs @@ -0,0 +1,16 @@ +using System.Threading.Tasks; +using BiliLite.Pages; + +namespace BiliLite.Models.Functions +{ + public class AddVolumeFunction : IShortcutFunction + { + public string Name { get; } = "音量+"; + + public async Task Action(object param) + { + if (!(param is PlayPage page)) return; + page.AddVolume(); + } + } +} diff --git a/src/BiliLite.UWP/Models/Functions/CancelFullscreenFunction.cs b/src/BiliLite.UWP/Models/Functions/CancelFullscreenFunction.cs new file mode 100644 index 00000000..9c44196a --- /dev/null +++ b/src/BiliLite.UWP/Models/Functions/CancelFullscreenFunction.cs @@ -0,0 +1,16 @@ +using System.Threading.Tasks; +using BiliLite.Pages; + +namespace BiliLite.Models.Functions +{ + public class CancelFullscreenFunction : IShortcutFunction + { + public string Name { get; } = "退出全屏"; + + public async Task Action(object param) + { + if (!(param is PlayPage page)) return; + page.CancelFullscreen(); + } + } +} diff --git a/src/BiliLite.UWP/Models/Functions/DebugThrowErrorFunction.cs b/src/BiliLite.UWP/Models/Functions/DebugThrowErrorFunction.cs new file mode 100644 index 00000000..dbbe03c8 --- /dev/null +++ b/src/BiliLite.UWP/Models/Functions/DebugThrowErrorFunction.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using BiliLite.Models.Exceptions; +using BiliLite.Services; + +namespace BiliLite.Models.Functions +{ + public class DebugThrowErrorFunction : IShortcutFunction + { + private static readonly ILogger _logger = GlobalLogger.FromCurrentType(); + + public string Name { get; } = "debug"; + + public async Task Action(object param) + { + _logger.Debug("debug throw error"); + var errList = new List(); + errList.FirstOrDefault().ToString(); + } + } +} diff --git a/src/BiliLite.UWP/Models/Functions/MinusVolumeFunction.cs b/src/BiliLite.UWP/Models/Functions/MinusVolumeFunction.cs new file mode 100644 index 00000000..a3f2072c --- /dev/null +++ b/src/BiliLite.UWP/Models/Functions/MinusVolumeFunction.cs @@ -0,0 +1,16 @@ +using System.Threading.Tasks; +using BiliLite.Pages; + +namespace BiliLite.Models.Functions +{ + public class MinusVolumeFunction : IShortcutFunction + { + public string Name { get; } = "音量-"; + + public async Task Action(object param) + { + if (!(param is PlayPage page)) return; + page.MinusVolume(); + } + } +} diff --git a/src/BiliLite.UWP/Models/Functions/PlayPauseFunction.cs b/src/BiliLite.UWP/Models/Functions/PlayPauseFunction.cs new file mode 100644 index 00000000..ce45384d --- /dev/null +++ b/src/BiliLite.UWP/Models/Functions/PlayPauseFunction.cs @@ -0,0 +1,23 @@ +using System.Threading.Tasks; +using BiliLite.Pages; + +namespace BiliLite.Models.Functions +{ + public class PlayPauseFunction : IShortcutFunction + { + public string Name { get; } = "播放/暂停"; + + public async Task Action(object param) + { + if (!(param is PlayPage page)) return; + if (page.IsPlaying) + { + page.Pause(); + } + else + { + page.Play(); + } + } + } +} diff --git a/src/BiliLite.UWP/Models/Functions/PositionBackFunction.cs b/src/BiliLite.UWP/Models/Functions/PositionBackFunction.cs new file mode 100644 index 00000000..271622ca --- /dev/null +++ b/src/BiliLite.UWP/Models/Functions/PositionBackFunction.cs @@ -0,0 +1,16 @@ +using System.Threading.Tasks; +using BiliLite.Pages; + +namespace BiliLite.Models.Functions +{ + public class PositionBackFunction : IShortcutFunction + { + public string Name { get; } = "回退3秒"; + + public async Task Action(object param) + { + if (!(param is PlayPage page)) return; + page.PositionBack(); + } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Requests/Api/RankAPI.cs b/src/BiliLite.UWP/Models/Requests/Api/RankAPI.cs index a9fd5e32..4ef8f9e1 100644 --- a/src/BiliLite.UWP/Models/Requests/Api/RankAPI.cs +++ b/src/BiliLite.UWP/Models/Requests/Api/RankAPI.cs @@ -1,4 +1,5 @@ -using BiliLite.Services; +using System.Threading.Tasks; +using BiliLite.Services; namespace BiliLite.Models.Requests.Api { @@ -19,14 +20,19 @@ public class RankAPI /// 分区ID /// all=全站,origin=原创,rookie=新人 /// - public ApiModel Rank(int rid, string type) + public async Task Rank(int rid, string type) { var api = new ApiModel() { method = RestSharp.Method.Get, baseUrl = $"{ApiHelper.API_BASE_URL}/x/web-interface/ranking/v2", - parameter = $"rid={rid}&type={type}" + parameter = $"rid={rid}&type={type}", }; + if (SettingService.Account.Logined) + { + api.need_cookie = true; + } + api.parameter = await ApiHelper.GetWbiSign(api.parameter); return api; } diff --git a/src/BiliLite.UWP/Models/Requests/Api/User/FavoriteAPI.cs b/src/BiliLite.UWP/Models/Requests/Api/User/FavoriteAPI.cs index bc723f5d..57679c58 100644 --- a/src/BiliLite.UWP/Models/Requests/Api/User/FavoriteAPI.cs +++ b/src/BiliLite.UWP/Models/Requests/Api/User/FavoriteAPI.cs @@ -73,6 +73,34 @@ public ApiModel AddFavorite(List favIds, string avid) return api; } + /// + /// 更新到收藏夹 + /// + /// + public ApiModel UpdateFavorite(List addFavIds,List delFavIds, string avid) + { + var addIds = ""; + foreach (var item in addFavIds) + { + addIds += item + ","; + } + addIds = Uri.EscapeDataString(addIds.TrimEnd(',')); + var delIds = ""; + foreach (var item in delFavIds) + { + delIds += item + ","; + } + delIds = Uri.EscapeDataString(delIds.TrimEnd(',')); + var api = new ApiModel() + { + method = RestSharp.Method.Post, + baseUrl = $"{ApiHelper.API_BASE_URL}/medialist/gateway/coll/resource/deal", + body = ApiHelper.MustParameter(AppKey, true) + $"&add_media_ids={addIds}&del_media_ids={delIds}&rid={avid}&type=2" + }; + api.body += ApiHelper.GetSign(api.body, AppKey); + return api; + } + /// /// 收藏收藏夹 /// diff --git a/src/BiliLite.UWP/Models/Requests/Api/VideoAPI.cs b/src/BiliLite.UWP/Models/Requests/Api/VideoAPI.cs index ea22679c..2587cca3 100644 --- a/src/BiliLite.UWP/Models/Requests/Api/VideoAPI.cs +++ b/src/BiliLite.UWP/Models/Requests/Api/VideoAPI.cs @@ -146,5 +146,18 @@ public ApiModel Tags(string aid) }; return api; } + + public ApiModel GetMediaList(string medisListId, string lastAid, int pagesize = 20) + { + var api = new ApiModel() + { + method = RestSharp.Method.Get, + baseUrl = $"https://api.bilibili.com/x/v2/medialist/resource/list", + parameter = + $"{ApiHelper.MustParameter(AppKey, true)}&type=1&biz_id={medisListId}&oid={lastAid}&otype=2&ps={pagesize}&direction=false&desc=true&sort_field=1&tid=0&with_current=false", + }; + api.parameter += ApiHelper.GetSign(api.parameter, AppKey); + return api; + } } } diff --git a/src/BiliLite.UWP/Modules/Live/LiveMessage.cs b/src/BiliLite.UWP/Modules/Live/LiveMessage.cs index 36308c4b..1fea8e3b 100644 --- a/src/BiliLite.UWP/Modules/Live/LiveMessage.cs +++ b/src/BiliLite.UWP/Modules/Live/LiveMessage.cs @@ -195,7 +195,7 @@ private MessageDelayType ParseMessage(string jsonMessage) { var obj = JObject.Parse(jsonMessage); var cmd = obj["cmd"].ToString(); - if (cmd == ("DANMU_MSG")) + if (cmd.StartsWith("DANMU_MSG")) { var msg = new DanmuMsgModel(); if (obj["info"] != null && obj["info"].ToArray().Length != 0) diff --git a/src/BiliLite.UWP/Modules/Other/FindMoreVM.cs b/src/BiliLite.UWP/Modules/Other/FindMoreVM.cs index 7795b457..87a1c744 100644 --- a/src/BiliLite.UWP/Modules/Other/FindMoreVM.cs +++ b/src/BiliLite.UWP/Modules/Other/FindMoreVM.cs @@ -45,7 +45,7 @@ public async void LoadEntrance() } catch (Exception ex) { - var handel = HandelError>(ex); + var handel = HandelError (ex); Notify.ShowMessageToast(handel.message); } finally diff --git a/src/BiliLite.UWP/Modules/RankVM.cs b/src/BiliLite.UWP/Modules/RankVM.cs deleted file mode 100644 index 1b39cc5f..00000000 --- a/src/BiliLite.UWP/Modules/RankVM.cs +++ /dev/null @@ -1,220 +0,0 @@ -using BiliLite.Models; -using BiliLite.Models.Requests.Api; -using Newtonsoft.Json.Linq; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using BiliLite.Extensions; - -namespace BiliLite.Modules -{ - public class RankVM : IModules - { - readonly RankAPI rankAPI; - public RankVM() - { - rankAPI = new RankAPI(); - } - private bool _loading = true; - public bool Loading - { - get { return _loading; } - set { _loading = value; DoPropertyChanged("Loading"); } - } - private RankRegionModel _current; - - public RankRegionModel Current - { - get { return _current; } - set { _current = value; DoPropertyChanged("Current"); } - } - private List _RegionItems; - public List RegionItems - { - get { return _RegionItems; } - set { _RegionItems = value; DoPropertyChanged("RegionItems"); } - } - public void LoadRankRegion(int rid = 0) - { - try - { - - Loading = true; - //var results = await rankAPI.RankRegion().Request(); - //if (results.status) - //{ - //var data = await results.GetJson>>(); - //if (data.success) - //{ - RegionItems = new List() { - new RankRegionModel(0,"全站"), - new RankRegionModel(0,"原创", RankRegionType.origin), - new RankRegionModel(0,"新人", RankRegionType.rookie), - new RankRegionModel(1,"动画"), - new RankRegionModel(168,"国创相关"), - new RankRegionModel(3,"音乐"), - new RankRegionModel(129,"舞蹈"), - new RankRegionModel(4,"游戏"), - new RankRegionModel(36,"知识"), - new RankRegionModel(188,"数码"), - new RankRegionModel(160,"生活"), - new RankRegionModel(211,"美食"), - new RankRegionModel(119,"鬼畜"), - new RankRegionModel(155,"时尚"), - new RankRegionModel(5,"娱乐"), - new RankRegionModel(181,"影视"), - - }; - Current = RegionItems.FirstOrDefault(x => x.rid == rid); - // } - // else - // { - // Notify.ShowMessageToast(data.message); - // } - //} - //else - //{ - // Notify.ShowMessageToast(results.message); - - //} - } - catch (Exception ex) - { - var handel = HandelError>>(ex); - Notify.ShowMessageToast(handel.message); - } - finally - { - Loading = false; - } - } - public async Task LoadRankDetail(RankRegionModel region) - { - try - { - Loading = true; - var results = await rankAPI.Rank(region.rid, region.type.ToString()).Request(); - if (results.status) - { - var data = await results.GetJson>(); - if (data.success) - { - region.ToolTip = data.data["note"].ToString(); - var result = await data.data["list"].ToString().DeserializeJson>(); - int i = 1; - result = result.ToList(); - foreach (var item in result) - { - item.rank = i; - i++; - } - region.Items = result; - } - else - { - Notify.ShowMessageToast(data.message); - } - } - else - { - Notify.ShowMessageToast(results.message); - - } - } - catch (Exception ex) - { - var handel = HandelError>>(ex); - Notify.ShowMessageToast(handel.message); - } - finally - { - Loading = false; - } - } - } - public enum RankRegionType - { - /// - /// 全部 - /// - all, - /// - /// 原创 - /// - origin, - /// - /// 新人 - /// - rookie - } - public class RankRegionModel : IModules - { - public RankRegionModel(int id, string rname, RankRegionType type = RankRegionType.all) - { - this.rid = id; - this.name = rname; - this.type = type; - } - public string name { get; set; } - public int rid { get; set; } - private string _tooltip = ""; - public string ToolTip - { - get { return _tooltip; } - set { _tooltip = value; DoPropertyChanged("ToolTip"); } - } - - public RankRegionType type { get; set; } - - private List _Items; - public List Items - { - get { return _Items; } - set { _Items = value; DoPropertyChanged("Items"); } - } - } - public class RankItemModel - { - public int rank { get; set; } - public string aid { get; set; } - public int videos { get; set; } - public int tid { get; set; } - public string tname { get; set; } - public int copyright { get; set; } - public string pic { get; set; } - public string title { get; set; } - public int pubdate { get; set; } - public int ctime { get; set; } - public string desc { get; set; } - public int state { get; set; } - public int duration { get; set; } - public int mission_id { get; set; } - - public RankItemOwnerModel owner { get; set; } - public RankItemStatModel stat { get; set; } - public string dynamic { get; set; } - public long cid { get; set; } - - public string bvid { get; set; } - public int score { get; set; } - } - public class RankItemStatModel - { - public long aid { get; set; } - public long view { get; set; } - public long danmaku { get; set; } - public long reply { get; set; } - public long favorite { get; set; } - public long coin { get; set; } - public long share { get; set; } - } - public class RankItemOwnerModel - { - public long mid { get; set; } - public string name { get; set; } - public string face { get; set; } - } - - -} diff --git a/src/BiliLite.UWP/Modules/RegionDetailVM.cs b/src/BiliLite.UWP/Modules/RegionDetailVM.cs index 082d9c03..bae8abdf 100644 --- a/src/BiliLite.UWP/Modules/RegionDetailVM.cs +++ b/src/BiliLite.UWP/Modules/RegionDetailVM.cs @@ -1,17 +1,16 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; using System.Threading.Tasks; using System.Collections.ObjectModel; using BiliLite.Modules.Home; using System.Windows.Input; using BiliLite.Extensions; using BiliLite.Models; -using Newtonsoft.Json.Linq; using Newtonsoft.Json; using BiliLite.Models.Requests.Api; using BiliLite.Services; +using BiliLite.ViewModels.Rank; namespace BiliLite.Modules { @@ -157,7 +156,7 @@ public async Task LoadHome() } catch (Exception ex) { - var handel = HandelError>>(ex); + var handel = HandelError>>(ex); Notify.ShowMessageToast(handel.message); } finally @@ -311,7 +310,7 @@ public async Task LoadHome() } catch (Exception ex) { - var handel = HandelError>>(ex); + var handel = HandelError>>(ex); Notify.ShowMessageToast(handel.message); } finally @@ -359,7 +358,7 @@ public async Task LoadList() } catch (Exception ex) { - var handel = HandelError>>(ex); + var handel = HandelError>>(ex); Notify.ShowMessageToast(handel.message); } finally diff --git a/src/BiliLite.UWP/Modules/Season/SeasonRankVM.cs b/src/BiliLite.UWP/Modules/Season/SeasonRankVM.cs index 50ef7e7f..461deb40 100644 --- a/src/BiliLite.UWP/Modules/Season/SeasonRankVM.cs +++ b/src/BiliLite.UWP/Modules/Season/SeasonRankVM.cs @@ -102,7 +102,7 @@ public async Task LoadRankDetail(SeasonRankModel region) } catch (Exception ex) { - var handel = HandelError>>(ex); + var handel = HandelError(ex); Notify.ShowMessageToast(handel.message); } finally diff --git a/src/BiliLite.UWP/NoTabMainPage.xaml.cs b/src/BiliLite.UWP/NoTabMainPage.xaml.cs index 09d7fb99..2f5d404c 100644 --- a/src/BiliLite.UWP/NoTabMainPage.xaml.cs +++ b/src/BiliLite.UWP/NoTabMainPage.xaml.cs @@ -5,6 +5,7 @@ using BiliLite.Services; using Microsoft.Extensions.DependencyInjection; using System; +using System.Collections.Generic; using System.Linq; using Windows.ApplicationModel.Core; using Windows.UI.Core; @@ -24,6 +25,7 @@ namespace BiliLite public sealed partial class NoTabMainPage : Page, IMainPage { private readonly ShortcutKeyService m_shortcutKeyService; + private readonly Stack m_titleStack = new Stack(); public NoTabMainPage() { @@ -92,6 +94,7 @@ private void Content_PointerPressed(object sender, PointerRoutedEventArgs e) { this.frame.GoBack(); e.Handled = true; + BackTitle(); } } @@ -103,9 +106,10 @@ private void Frame_Navigated(object sender, NavigationEventArgs e) { txtTitle.Text = "哔哩哔哩 UWP"; } - if (e.Content is Pages.BasePage) + if (e.Content is Pages.BasePage && e.NavigationMode!=NavigationMode.Back) { - txtTitle.Text = (e.Content as BasePage).Title; + var title = (e.Content as BasePage).Title; + PushTitle(title); } if (frame.CanGoBack) @@ -141,7 +145,7 @@ private void MessageCenter_ChangeTitleEvent(object sender, string e) { if (mode == 1) { - txtTitle.Text = e; + ChangeTitle(e); } } @@ -149,10 +153,9 @@ private void NavigationHelper_NavigateToPageEvent(object sender, NavigationInfo { if (mode == 1) { - txtTitle.Text = e.title; + //PushTitle(e.title); frame.Navigate(e.page, e.parameters); (frame.Content as Page).NavigationCacheMode = NavigationCacheMode.Required; - } else { @@ -165,6 +168,7 @@ private void btnBack_Click(object sender, RoutedEventArgs e) if (frame.CanGoBack) { frame.GoBack(); + BackTitle(); } } @@ -202,6 +206,29 @@ private void imgViewer_CloseEvent(object sender, EventArgs e) gridViewer.Visibility = Visibility.Collapsed; } } + + private void BackTitle() + { + if (m_titleStack.Count == 0) + { + txtTitle.Text = "哔哩哔哩 UWP"; + return; + } + + var title = m_titleStack.Pop(); + txtTitle.Text = title; + } + + private void PushTitle(string title) + { + m_titleStack.Push(txtTitle.Text); + txtTitle.Text = title; + } + + private void ChangeTitle(string title) + { + txtTitle.Text = title; + } } public class NewInstanceFrame : Grid @@ -250,8 +277,7 @@ public bool Navigate(Type sourcePageType, object parameter = null) //跳转页面 (this.Children.Last() as Frame).Navigate(sourcePageType, parameter); - - + return true; } public bool CanGoBack diff --git a/src/BiliLite.UWP/Pages/BasePage.cs b/src/BiliLite.UWP/Pages/BasePage.cs index 86b7d963..2469317e 100644 --- a/src/BiliLite.UWP/Pages/BasePage.cs +++ b/src/BiliLite.UWP/Pages/BasePage.cs @@ -28,6 +28,9 @@ protected override void OnNavigatingFrom(NavigatingCancelEventArgs e) public class PlayPage : BasePage { public PlayerControl Player { get; set; } + + public bool IsPlaying => Player.IsPlaying; + public void Pause() { Player.PlayerInstance.Pause(); @@ -37,6 +40,25 @@ public void Play() Player.PlayerInstance.Play(); } + public void PositionBack() + { + Player.PositionBack(); + } + public void AddVolume() + { + Player.AddVolume(); + } + + public void MinusVolume() + { + Player.MinusVolume(); + } + + public void CancelFullscreen() + { + Player.CancelFullscreen(); + } + public void DisposePlayer() { Player?.Dispose(); diff --git a/src/BiliLite.UWP/Pages/LiveDetailPage.xaml.cs b/src/BiliLite.UWP/Pages/LiveDetailPage.xaml.cs index d0c87ab0..022b0cb0 100644 --- a/src/BiliLite.UWP/Pages/LiveDetailPage.xaml.cs +++ b/src/BiliLite.UWP/Pages/LiveDetailPage.xaml.cs @@ -845,6 +845,7 @@ private async void SetFullWindow(bool e) private async void SetFullScreen(bool e) { + m_danmakuController.SetFullscreen(e); if (e) { await m_playerController.ScreenState.Fullscreen(); diff --git a/src/BiliLite.UWP/Pages/RankPage.xaml b/src/BiliLite.UWP/Pages/RankPage.xaml index 94af2040..12906788 100644 --- a/src/BiliLite.UWP/Pages/RankPage.xaml +++ b/src/BiliLite.UWP/Pages/RankPage.xaml @@ -11,7 +11,9 @@ xmlns:modules="using:BiliLite.Modules" xmlns:toolkit="using:Microsoft.Toolkit.Uwp.UI.Controls" xmlns:winui="using:Microsoft.UI.Xaml.Controls" - xmlns:fa="using:FontAwesome5" + xmlns:fa="using:FontAwesome5" + xmlns:rank="using:BiliLite.Models.Common.Rank" + xmlns:rank1="using:BiliLite.ViewModels.Rank" Background="Transparent"> @@ -20,7 +22,7 @@ - + @@ -30,8 +32,8 @@ - - + + @@ -40,7 +42,7 @@ - + - + @@ -79,20 +81,20 @@ - + - + - - + + - - 观看: 弹幕: + + 观看: 弹幕: - UP: + UP: @@ -103,6 +105,6 @@ - + diff --git a/src/BiliLite.UWP/Pages/RankPage.xaml.cs b/src/BiliLite.UWP/Pages/RankPage.xaml.cs index 9cc2e133..07ef30e1 100644 --- a/src/BiliLite.UWP/Pages/RankPage.xaml.cs +++ b/src/BiliLite.UWP/Pages/RankPage.xaml.cs @@ -6,6 +6,9 @@ using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Input; using Windows.UI.Xaml.Navigation; +using BiliLite.Models.Common.Rank; +using BiliLite.ViewModels.Rank; +using Microsoft.Extensions.DependencyInjection; // https://go.microsoft.com/fwlink/?LinkId=234238 上介绍了“空白页”项模板 @@ -16,13 +19,14 @@ namespace BiliLite.Pages /// public sealed partial class RankPage : BasePage { - readonly RankVM rankVM; + readonly RankViewModel m_viewModel; public RankPage() { + m_viewModel = App.ServiceProvider.GetRequiredService(); this.InitializeComponent(); Title = "排行榜"; - rankVM = new RankVM(); } + protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); @@ -33,7 +37,7 @@ protected override void OnNavigatedTo(NavigationEventArgs e) { rid = e.Parameter.ToInt32(); } - rankVM.LoadRankRegion(rid); + m_viewModel.LoadRankRegion(rid); } } @@ -43,10 +47,10 @@ private async void pivot_SelectionChanged(object sender, SelectionChangedEventAr { return; } - var data = pivot.SelectedItem as RankRegionModel; + var data = pivot.SelectedItem as RankRegionViewModel; if (data.Items == null || data.Items.Count == 0) { - await rankVM.LoadRankDetail(data); + await m_viewModel.LoadRankDetail(data); } } @@ -63,8 +67,8 @@ private void RankItemModelOpen(object sender, RankItemModel item, bool dontGoTo { icon = Symbol.Play, page = typeof(VideoDetailPage), - title = item.title, - parameters = item.aid, + title = item.Title, + parameters = item.Aid, dontGoTo = dontGoTo }); } @@ -80,7 +84,7 @@ private void AdaptiveGridView_PointerPressed(object sender, PointerRoutedEventAr private void AddToWatchLater_Click(object sender, RoutedEventArgs e) { var data = (sender as MenuFlyoutItem).DataContext as RankItemModel; - Modules.User.WatchLaterVM.Instance.AddToWatchlater(data.aid); + Modules.User.WatchLaterVM.Instance.AddToWatchlater(data.Aid); } } } diff --git a/src/BiliLite.UWP/Pages/SettingPage.xaml b/src/BiliLite.UWP/Pages/SettingPage.xaml index 6476c4ea..81fa15f0 100644 --- a/src/BiliLite.UWP/Pages/SettingPage.xaml +++ b/src/BiliLite.UWP/Pages/SettingPage.xaml @@ -339,6 +339,9 @@ 锁定播放器亮度设置(播放器内修改亮度时不写设置) + 播放速度菜单 + + 自动打开AI字幕 部分自动生成的AI字幕会与视频自带字幕冲突 diff --git a/src/BiliLite.UWP/Pages/SettingPage.xaml.cs b/src/BiliLite.UWP/Pages/SettingPage.xaml.cs index bb18e10b..a46bb7ce 100644 --- a/src/BiliLite.UWP/Pages/SettingPage.xaml.cs +++ b/src/BiliLite.UWP/Pages/SettingPage.xaml.cs @@ -21,6 +21,7 @@ using Microsoft.Extensions.DependencyInjection; using System.Threading.Tasks; using Windows.ApplicationModel.Core; +using BiliLite.Dialogs; // https://go.microsoft.com/fwlink/?LinkId=234238 上介绍了“空白页”项模板 @@ -1230,5 +1231,11 @@ private async void DanmuSettingFilterImport_OnClick(object sender, RoutedEventAr { await settingVM.ImportDanmuFilter(); } + + private async void BtnEditPlaySpeedMenu_OnClick(object sender, RoutedEventArgs e) + { + var dialog = App.ServiceProvider.GetRequiredService(); + await dialog.ShowAsync(); + } } } diff --git a/src/BiliLite.UWP/Pages/UserInfoPage.xaml.cs b/src/BiliLite.UWP/Pages/UserInfoPage.xaml.cs index df5d2e82..9e49c5eb 100644 --- a/src/BiliLite.UWP/Pages/UserInfoPage.xaml.cs +++ b/src/BiliLite.UWP/Pages/UserInfoPage.xaml.cs @@ -14,8 +14,8 @@ using BiliLite.ViewModels.UserDynamic; using Microsoft.Extensions.DependencyInjection; using BiliLite.Models.Common.Video; -using BiliLite.Modules; using System.Collections.Generic; +using BiliLite.Services.Biz; // https://go.microsoft.com/fwlink/?LinkId=234238 上介绍了“空白页”项模板 @@ -41,6 +41,7 @@ public class UserInfoParameter /// public sealed partial class UserInfoPage : BasePage, IRefreshablePage { + private readonly MediaListService m_mediaListService; readonly UserDynamicViewModel m_userDynamicViewModel; UserDetailViewModel m_viewModel; UserSubmitVideoViewModel m_userSubmitVideoViewModel; @@ -54,6 +55,7 @@ public sealed partial class UserInfoPage : BasePage, IRefreshablePage public UserInfoPage() { m_viewModel = App.ServiceProvider.GetRequiredService(); + m_mediaListService = App.ServiceProvider.GetRequiredService(); this.InitializeComponent(); Title = "用户中心"; m_userSubmitVideoViewModel = App.ServiceProvider.GetService(); @@ -417,19 +419,25 @@ public async Task Refresh() throw new System.NotImplementedException(); } - private void BtnPlayAll_OnTapped(object sender, TappedRoutedEventArgs e) + private async void BtnPlayAll_OnTapped(object sender, TappedRoutedEventArgs e) { var items = new List(); - foreach (var item in m_userSubmitVideoViewModel.SubmitVideoItems) + var mediaList = await m_mediaListService.GetMediaList(m_userSubmitVideoViewModel.PlayAllMediaListId); + + if (mediaList == null) + { + return; + } + + foreach (var item in mediaList) { items.Add(new VideoPlaylistItem() { - Cover = item.Pic, - Author = item.Author, - Id = item.Aid, + Cover = item.Cover, + Author = item.Upper.Name, + Id = item.Id.ToString(), Title = item.Title }); - } MessageCenter.NavigateToPage(this, new NavigationInfo() @@ -442,6 +450,8 @@ private void BtnPlayAll_OnTapped(object sender, TappedRoutedEventArgs e) Index = 0, Playlist = items, Title = $"{m_viewModel.UserInfo.Name}:全部视频", + MediaListId = m_userSubmitVideoViewModel.PlayAllMediaListId, + IsOnlineMediaList = true, } }); } diff --git a/src/BiliLite.UWP/Pages/VideoDetailPage.xaml b/src/BiliLite.UWP/Pages/VideoDetailPage.xaml index 6f427333..708095d5 100644 --- a/src/BiliLite.UWP/Pages/VideoDetailPage.xaml +++ b/src/BiliLite.UWP/Pages/VideoDetailPage.xaml @@ -66,14 +66,17 @@