Skip to content
This repository has been archived by the owner on Dec 20, 2023. It is now read-only.

Commit

Permalink
在播放关联视频时固定播放模式 (#978)
Browse files Browse the repository at this point in the history
  • Loading branch information
Richasy authored Apr 2, 2022
1 parent 9b650fe commit dde88bc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ private async void ResetAsync()
ChoiceCollection.Clear();
TagCollection.Clear();
ReplyModuleViewModel.Instance.SetInformation(0, Models.Enums.Bili.ReplyType.None);
var preferPlayerMode = _settingsToolkit.ReadLocalSetting(SettingNames.DefaultPlayerDisplayMode, PlayerDisplayMode.Default);
PlayerDisplayMode = preferPlayerMode;
Controller.CleanupLiveSocket();
await ClearInitViewModelAsync();
}
Expand All @@ -104,14 +102,9 @@ private async Task LoadVideoDetailAsync(string videoId, bool isRefresh)
IsDetailLoading = true;
try
{
if (videoId.StartsWith("bv", StringComparison.OrdinalIgnoreCase))
{
_videoDetail = await Controller.GetVideoDetailAsync(videoId);
}
else
{
_videoDetail = await Controller.GetVideoDetailAsync(Convert.ToInt64(videoId.Replace("av", string.Empty)));
}
_videoDetail = videoId.StartsWith("bv", StringComparison.OrdinalIgnoreCase)
? await Controller.GetVideoDetailAsync(videoId)
: await Controller.GetVideoDetailAsync(Convert.ToInt64(videoId.Replace("av", string.Empty)));
}
catch (Exception ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
using Windows.Storage.Streams;
using Windows.UI.ViewManagement;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Input;

namespace Richasy.Bili.ViewModels.Uwp
{
Expand Down Expand Up @@ -161,8 +160,9 @@ public async Task BackToHomeAsync()
/// </summary>
/// <param name="vm">视图模型.</param>
/// <param name="isRefresh">是否刷新.</param>
/// <param name="shouldResetMode">是否需要重置播放模式.</param>
/// <returns><see cref="Task"/>.</returns>
public async Task LoadAsync(object vm, bool isRefresh = false)
public async Task LoadAsync(object vm, bool isRefresh = false, bool shouldResetMode = true)
{
var videoId = string.Empty;
var seasonId = 0;
Expand Down Expand Up @@ -217,7 +217,7 @@ record = r;
};
}

await LoadAsync(record, isRefresh);
await LoadAsync(record, isRefresh, shouldResetMode);

void HandleVideoViewModel(VideoViewModel internalVM)
{
Expand Down Expand Up @@ -246,8 +246,9 @@ void HandleVideoViewModel(VideoViewModel internalVM)
/// </summary>
/// <param name="record">播放快照.</param>
/// <param name="isRefresh">是否刷新.</param>
/// <param name="shouldResetMode">是否需要重置播放模式.</param>
/// <returns><see cref="Task"/>.</returns>
public async Task LoadAsync(CurrentPlayingRecord record, bool isRefresh = false)
public async Task LoadAsync(CurrentPlayingRecord record, bool isRefresh = false, bool shouldResetMode = true)
{
_videoType = record.VideoType;
var isReleated = record.IsRelated;
Expand All @@ -258,6 +259,12 @@ public async Task LoadAsync(CurrentPlayingRecord record, bool isRefresh = false)
IsPlayInformationError = false;
InitializePlaybackRateProperties();

if (shouldResetMode)
{
var preferPlayerMode = _settingsToolkit.ReadLocalSetting(SettingNames.DefaultPlayerDisplayMode, PlayerDisplayMode.Default);
PlayerDisplayMode = preferPlayerMode;
}

if (!isReleated)
{
_historyVideoList.Clear();
Expand Down Expand Up @@ -761,19 +768,21 @@ public async Task ClearInitViewModelAsync()
/// <returns><see cref="Task"/>.</returns>
public async Task PlayNextVideoAsync()
{
var previousDisplayMode = PlayerDisplayMode;
if (IsShowViewLater)
{
var index = ViewLaterVideoCollection.IndexOf(ViewLaterVideoCollection.FirstOrDefault(p => p.IsSelected));
if (index != -1 && index < ViewLaterVideoCollection.Count)
{
var nextVideo = ViewLaterVideoCollection[index + 1];
await LoadAsync(nextVideo);
await LoadAsync(nextVideo, shouldResetMode: false);
}
}
else if (RelatedVideoCollection.Count > 0)
{
var first = RelatedVideoCollection.First();
await LoadAsync(first);
await LoadAsync(first, shouldResetMode: false);
PlayerDisplayMode = previousDisplayMode;
}
}

Expand Down

0 comments on commit dde88bc

Please sign in to comment.