From 859ed021ed6156747b684dc9efff95a3c5aaf82d Mon Sep 17 00:00:00 2001 From: Richasy Date: Sat, 25 Sep 2021 19:13:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=87=8D=E5=A4=8D=E8=BF=9B?= =?UTF-8?q?=E5=85=A5=E7=9B=B4=E6=92=AD=E9=97=B4=E6=97=A0=E6=B3=95=E6=92=AD?= =?UTF-8?q?=E6=94=BE=E7=9A=84=E9=97=AE=E9=A2=98=20(#300)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PlayerViewModel.Methods.cs | 51 +++++++++---------- .../Common/PlayerViewModel/PlayerViewModel.cs | 2 +- 2 files changed, 25 insertions(+), 28 deletions(-) diff --git a/src/ViewModels/ViewModels.Uwp/Common/PlayerViewModel/PlayerViewModel.Methods.cs b/src/ViewModels/ViewModels.Uwp/Common/PlayerViewModel/PlayerViewModel.Methods.cs index 4a0cf5d81..a654a8b73 100644 --- a/src/ViewModels/ViewModels.Uwp/Common/PlayerViewModel/PlayerViewModel.Methods.cs +++ b/src/ViewModels/ViewModels.Uwp/Common/PlayerViewModel/PlayerViewModel.Methods.cs @@ -145,37 +145,34 @@ private async Task LoadPgcDetailAsync(int episodeId, int seasonId = 0, bool isRe await ChangePgcEpisodeAsync(id); } - private async Task LoadLiveDetailAsync(int roomId, bool isRefresh) + private async Task LoadLiveDetailAsync(int roomId) { - if (_liveDetail == null || RoomId != roomId.ToString() || isRefresh) - { - Reset(); - IsLive = true; - IsDetailLoading = true; - IsShowReply = false; - RoomId = roomId.ToString(); + Reset(); + IsLive = true; + IsDetailLoading = true; + IsShowReply = false; + RoomId = roomId.ToString(); - try - { - var detail = await Controller.GetLiveRoomDetailAsync(roomId); - _liveDetail = detail; - } - catch (Exception ex) - { - IsDetailError = true; - DetailErrorText = _resourceToolkit.GetLocaleString(LanguageNames.RequestLiveFailed) + $"\n{ex.Message}"; - IsDetailLoading = false; - return; - } - - InitializeLiveDetail(); + try + { + var detail = await Controller.GetLiveRoomDetailAsync(roomId); + _liveDetail = detail; + } + catch (Exception ex) + { + IsDetailError = true; + DetailErrorText = _resourceToolkit.GetLocaleString(LanguageNames.RequestLiveFailed) + $"\n{ex.Message}"; IsDetailLoading = false; - - await InitializeUserRelationAsync(); - await Controller.ConnectToLiveRoomAsync(roomId); - await ChangeLiveQualityAsync(4); - await Controller.SendLiveHeartBeatAsync(); + return; } + + InitializeLiveDetail(); + IsDetailLoading = false; + + await InitializeUserRelationAsync(); + await Controller.ConnectToLiveRoomAsync(roomId); + await ChangeLiveQualityAsync(4); + await Controller.SendLiveHeartBeatAsync(); } private void InitializeVideoDetail() diff --git a/src/ViewModels/ViewModels.Uwp/Common/PlayerViewModel/PlayerViewModel.cs b/src/ViewModels/ViewModels.Uwp/Common/PlayerViewModel/PlayerViewModel.cs index 627a0b75f..a371bcb5d 100644 --- a/src/ViewModels/ViewModels.Uwp/Common/PlayerViewModel/PlayerViewModel.cs +++ b/src/ViewModels/ViewModels.Uwp/Common/PlayerViewModel/PlayerViewModel.cs @@ -129,7 +129,7 @@ public async Task LoadAsync(object vm, bool isRefresh = false) await LoadPgcDetailAsync(Convert.ToInt32(videoId), seasonId, isRefresh); break; case VideoType.Live: - await LoadLiveDetailAsync(Convert.ToInt32(videoId), isRefresh); + await LoadLiveDetailAsync(Convert.ToInt32(videoId)); break; default: break;