diff --git a/src/App/Assets/DashVideoTemplate.xml b/src/App/Assets/DashVideoTemplate.xml index f75c257ee..b0f243d7f 100644 --- a/src/App/Assets/DashVideoTemplate.xml +++ b/src/App/Assets/DashVideoTemplate.xml @@ -1,13 +1,12 @@ - + - - - {audio} - - - + + {video} + + + {audio} + diff --git a/src/App/Assets/DashVideoWithoutAudioTemplate.xml b/src/App/Assets/DashVideoWithoutAudioTemplate.xml index 891912a06..a4593ba15 100644 --- a/src/App/Assets/DashVideoWithoutAudioTemplate.xml +++ b/src/App/Assets/DashVideoWithoutAudioTemplate.xml @@ -1,7 +1,6 @@ - + - + {video} diff --git a/src/Lib/Lib.Implementation/PlayerProvider/PlayerProvider.Extension.cs b/src/Lib/Lib.Implementation/PlayerProvider/PlayerProvider.Extension.cs index d13092a2a..f9b1de128 100644 --- a/src/Lib/Lib.Implementation/PlayerProvider/PlayerProvider.Extension.cs +++ b/src/Lib/Lib.Implementation/PlayerProvider/PlayerProvider.Extension.cs @@ -80,6 +80,7 @@ private async Task InternalGetDashAsync(string cid, string aid var isPgc = string.IsNullOrEmpty(aid) && !string.IsNullOrEmpty(seasonType); var url = isPgc ? ApiConstants.Pgc.PlayInformation(proxy) : ApiConstants.Video.PlayInformation; + var requestType = isPgc ? RequestClientType.Web : RequestClientType.IOS; var queryParameters = new Dictionary { @@ -113,7 +114,7 @@ private async Task InternalGetDashAsync(string cid, string aid otherQuery = $"area={area}"; } - var request = await _httpProvider.GetRequestMessageAsync(HttpMethod.Get, url, queryParameters, RequestClientType.IOS, additionalQuery: otherQuery); + var request = await _httpProvider.GetRequestMessageAsync(HttpMethod.Get, url, queryParameters, requestType, additionalQuery: otherQuery); var response = await _httpProvider.SendAsync(request); var data = await _httpProvider.ParseAsync, ServerResponse2>(response, (str) => { diff --git a/src/Models/Models.Data/Player/SegmentInformation.cs b/src/Models/Models.Data/Player/SegmentInformation.cs index 83236048f..31da6bbbd 100644 --- a/src/Models/Models.Data/Player/SegmentInformation.cs +++ b/src/Models/Models.Data/Player/SegmentInformation.cs @@ -32,7 +32,8 @@ public SegmentInformation( int width, int height, string initialization, - string indexRange) + string indexRange, + int startWithSap = 1) { Id = id; BaseUrl = baseUrl; @@ -44,6 +45,7 @@ public SegmentInformation( Height = height; Initialization = initialization; IndexRange = indexRange; + StartWithSap = startWithSap; } /// @@ -96,6 +98,11 @@ public SegmentInformation( /// public string IndexRange { get; } + /// + /// None. + /// + public int StartWithSap { get; } + /// public override bool Equals(object obj) => obj is SegmentInformation information && Id == information.Id; diff --git a/src/ViewModels/ViewModels.Uwp/Core/NativePlayerViewModel/NativePlayerViewModel.Methods.cs b/src/ViewModels/ViewModels.Uwp/Core/NativePlayerViewModel/NativePlayerViewModel.Methods.cs index bda95ea51..5f6d6eb3f 100644 --- a/src/ViewModels/ViewModels.Uwp/Core/NativePlayerViewModel/NativePlayerViewModel.Methods.cs +++ b/src/ViewModels/ViewModels.Uwp/Core/NativePlayerViewModel/NativePlayerViewModel.Methods.cs @@ -23,7 +23,7 @@ public sealed partial class NativePlayerViewModel private HttpClient GetVideoClient() { var httpClient = new HttpClient(); - httpClient.DefaultRequestHeaders.Referer = new Uri("https://www.bilibili.com"); + httpClient.DefaultRequestHeaders.Add("Referer", "https://www.bilibili.com"); httpClient.DefaultRequestHeaders.Add("User-Agent", ServiceConstants.DefaultUserAgentString); return httpClient; } @@ -37,7 +37,7 @@ private async Task LoadDashVideoSourceAsync() var mpdStr = await _fileToolkit.ReadPackageFile(mpdFilePath); var videoStr = - $@" + $@" @@ -65,6 +65,7 @@ private async Task LoadDashVideoSourceAsync() var stream = new MemoryStream(Encoding.UTF8.GetBytes(mpdStr)).AsInputStream(); var source = await AdaptiveMediaSource.CreateFromStreamAsync(stream, new Uri(_video.BaseUrl), "application/dash+xml", httpClient); + source.MediaSource.AdvancedSettings.AllSegmentsIndependent = true; Debug.Assert(source.Status == AdaptiveMediaSourceCreationStatus.Success, "解析MPD失败"); source.MediaSource.DownloadRequested += (sender, args) => {