未验证 提交 deee4e67 编写于 作者: R Richasy 提交者: GitHub

修复PGC内容无法播放以及自动生成字幕未显示的问题 (#1705)

* 修复自动生成的字幕没有显示的问题

* 修复PGC内容播放问题
上级 e5f05aed
...@@ -1330,7 +1330,7 @@ ...@@ -1330,7 +1330,7 @@
<Version>2.8.2-prerelease.220830001</Version> <Version>2.8.2-prerelease.220830001</Version>
</PackageReference> </PackageReference>
<PackageReference Include="Newtonsoft.Json"> <PackageReference Include="Newtonsoft.Json">
<Version>13.0.2</Version> <Version>13.0.3</Version>
</PackageReference> </PackageReference>
<PackageReference Include="Richasy.FluentIcon.Regular.UWP"> <PackageReference Include="Richasy.FluentIcon.Regular.UWP">
<Version>1.1.150</Version> <Version>1.1.150</Version>
......
<MPD xmlns="urn:mpeg:DASH:schema:MPD:2011" profiles="urn:mpeg:dash:profile:isoff-on-demand:2011" type="static" <MPD xmlns="urn:mpeg:DASH:schema:MPD:2011" profiles="urn:mpeg:dash:profile:isoff-on-demand:2011" type="static">
minBufferTime="{bufferTime}">
<Period start="PT0S"> <Period start="PT0S">
<AdaptationSet group="1"> <AdaptationSet>
<ContentComponent contentType="audio" id="1" /> <ContentComponent contentType="video" id="1" />
{audio}
</AdaptationSet>
<AdaptationSet group="2">
<ContentComponent contentType="video" id="2" />
{video} {video}
</AdaptationSet> </AdaptationSet>
<AdaptationSet>
<ContentComponent contentType="audio" id="2" />
{audio}
</AdaptationSet>
</Period> </Period>
</MPD> </MPD>
<MPD xmlns="urn:mpeg:DASH:schema:MPD:2011" profiles="urn:mpeg:dash:profile:isoff-on-demand:2011" type="static" <MPD xmlns="urn:mpeg:DASH:schema:MPD:2011" profiles="urn:mpeg:dash:profile:isoff-on-demand:2011" type="static">
minBufferTime="{bufferTime}">
<Period start="PT0S"> <Period start="PT0S">
<AdaptationSet group="1"> <AdaptationSet>
<ContentComponent contentType="video" id="1" /> <ContentComponent contentType="video" id="1" />
{video} {video}
</AdaptationSet> </AdaptationSet>
......
...@@ -129,7 +129,7 @@ ...@@ -129,7 +129,7 @@
<Version>6.2.14</Version> <Version>6.2.14</Version>
</PackageReference> </PackageReference>
<PackageReference Include="NLog"> <PackageReference Include="NLog">
<Version>5.1.1</Version> <Version>5.2.0</Version>
</PackageReference> </PackageReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Autofac" Version="7.0.0" /> <PackageReference Include="Autofac" Version="7.0.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.1.0" /> <PackageReference Include="CommunityToolkit.Mvvm" Version="8.1.0" />
<PackageReference Include="NLog" Version="5.1.3" /> <PackageReference Include="NLog" Version="5.2.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>
...@@ -135,7 +135,7 @@ ...@@ -135,7 +135,7 @@
<Version>6.2.14</Version> <Version>6.2.14</Version>
</PackageReference> </PackageReference>
<PackageReference Include="Newtonsoft.Json"> <PackageReference Include="Newtonsoft.Json">
<Version>13.0.2</Version> <Version>13.0.3</Version>
</PackageReference> </PackageReference>
<PackageReference Include="Win2D.uwp"> <PackageReference Include="Win2D.uwp">
<Version>1.26.0</Version> <Version>1.26.0</Version>
......
...@@ -80,6 +80,7 @@ namespace Bili.Lib ...@@ -80,6 +80,7 @@ namespace Bili.Lib
var isPgc = string.IsNullOrEmpty(aid) && !string.IsNullOrEmpty(seasonType); var isPgc = string.IsNullOrEmpty(aid) && !string.IsNullOrEmpty(seasonType);
var url = isPgc ? ApiConstants.Pgc.PlayInformation(proxy) : ApiConstants.Video.PlayInformation; var url = isPgc ? ApiConstants.Pgc.PlayInformation(proxy) : ApiConstants.Video.PlayInformation;
var requestType = isPgc ? RequestClientType.Web : RequestClientType.IOS;
var queryParameters = new Dictionary<string, string> var queryParameters = new Dictionary<string, string>
{ {
...@@ -113,7 +114,7 @@ namespace Bili.Lib ...@@ -113,7 +114,7 @@ namespace Bili.Lib
otherQuery = $"area={area}"; 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 response = await _httpProvider.SendAsync(request);
var data = await _httpProvider.ParseAsync<ServerResponse<PlayerInformation>, ServerResponse2<PlayerInformation>>(response, (str) => var data = await _httpProvider.ParseAsync<ServerResponse<PlayerInformation>, ServerResponse2<PlayerInformation>>(response, (str) =>
{ {
......
...@@ -333,7 +333,7 @@ namespace Bili.Lib ...@@ -333,7 +333,7 @@ namespace Bili.Lib
url = "https:" + url; url = "https:" + url;
} }
var request = await _httpProvider.GetRequestMessageAsync(HttpMethod.Get, url); var request = await _httpProvider.GetRequestMessageAsync(HttpMethod.Get, url, type: RequestClientType.IOS, needCookie: true);
var response = await _httpProvider.SendAsync(request); var response = await _httpProvider.SendAsync(request);
var result = await _httpProvider.ParseAsync<SubtitleDetailResponse>(response); var result = await _httpProvider.ParseAsync<SubtitleDetailResponse>(response);
return result.Body.Select(p => _playerAdapter.ConvertToSubtitleInformation(p)).ToList(); return result.Body.Select(p => _playerAdapter.ConvertToSubtitleInformation(p)).ToList();
......
...@@ -32,7 +32,8 @@ namespace Bili.Models.Data.Player ...@@ -32,7 +32,8 @@ namespace Bili.Models.Data.Player
int width, int width,
int height, int height,
string initialization, string initialization,
string indexRange) string indexRange,
int startWithSap = 1)
{ {
Id = id; Id = id;
BaseUrl = baseUrl; BaseUrl = baseUrl;
...@@ -44,6 +45,7 @@ namespace Bili.Models.Data.Player ...@@ -44,6 +45,7 @@ namespace Bili.Models.Data.Player
Height = height; Height = height;
Initialization = initialization; Initialization = initialization;
IndexRange = indexRange; IndexRange = indexRange;
StartWithSap = startWithSap;
} }
/// <summary> /// <summary>
...@@ -96,6 +98,11 @@ namespace Bili.Models.Data.Player ...@@ -96,6 +98,11 @@ namespace Bili.Models.Data.Player
/// </summary> /// </summary>
public string IndexRange { get; } public string IndexRange { get; }
/// <summary>
/// None.
/// </summary>
public int StartWithSap { get; }
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) => obj is SegmentInformation information && Id == information.Id; public override bool Equals(object obj) => obj is SegmentInformation information && Id == information.Id;
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
<Version>6.2.14</Version> <Version>6.2.14</Version>
</PackageReference> </PackageReference>
<PackageReference Include="Newtonsoft.Json"> <PackageReference Include="Newtonsoft.Json">
<Version>13.0.2</Version> <Version>13.0.3</Version>
</PackageReference> </PackageReference>
<PackageReference Include="ToolGood.Words"> <PackageReference Include="ToolGood.Words">
<Version>3.0.3.1</Version> <Version>3.0.3.1</Version>
......
...@@ -23,7 +23,7 @@ namespace Bili.ViewModels.Uwp.Core ...@@ -23,7 +23,7 @@ namespace Bili.ViewModels.Uwp.Core
private HttpClient GetVideoClient() private HttpClient GetVideoClient()
{ {
var httpClient = new HttpClient(); 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); httpClient.DefaultRequestHeaders.Add("User-Agent", ServiceConstants.DefaultUserAgentString);
return httpClient; return httpClient;
} }
...@@ -37,7 +37,7 @@ namespace Bili.ViewModels.Uwp.Core ...@@ -37,7 +37,7 @@ namespace Bili.ViewModels.Uwp.Core
var mpdStr = await _fileToolkit.ReadPackageFile(mpdFilePath); var mpdStr = await _fileToolkit.ReadPackageFile(mpdFilePath);
var videoStr = var videoStr =
$@"<Representation bandwidth=""{_video.Bandwidth}"" codecs=""{_video.Codecs}"" height=""{_video.Height}"" mimeType=""{_video.MimeType}"" id=""{_video.Id}"" width=""{_video.Width}""> $@"<Representation bandwidth=""{_video.Bandwidth}"" codecs=""{_video.Codecs}"" height=""{_video.Height}"" mimeType=""{_video.MimeType}"" id=""{_video.Id}"" width=""{_video.Width}"" startWithSap=""{_video.StartWithSap}"">
<BaseURL></BaseURL> <BaseURL></BaseURL>
<SegmentBase indexRange=""{_video.IndexRange}""> <SegmentBase indexRange=""{_video.IndexRange}"">
<Initialization range=""{_video.Initialization}"" /> <Initialization range=""{_video.Initialization}"" />
...@@ -65,6 +65,7 @@ namespace Bili.ViewModels.Uwp.Core ...@@ -65,6 +65,7 @@ namespace Bili.ViewModels.Uwp.Core
var stream = new MemoryStream(Encoding.UTF8.GetBytes(mpdStr)).AsInputStream(); var stream = new MemoryStream(Encoding.UTF8.GetBytes(mpdStr)).AsInputStream();
var source = await AdaptiveMediaSource.CreateFromStreamAsync(stream, new Uri(_video.BaseUrl), "application/dash+xml", httpClient); 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失败"); Debug.Assert(source.Status == AdaptiveMediaSourceCreationStatus.Success, "解析MPD失败");
source.MediaSource.DownloadRequested += (sender, args) => source.MediaSource.DownloadRequested += (sender, args) =>
{ {
......
...@@ -222,7 +222,7 @@ ...@@ -222,7 +222,7 @@
<Version>7.1.3</Version> <Version>7.1.3</Version>
</PackageReference> </PackageReference>
<PackageReference Include="NLog"> <PackageReference Include="NLog">
<Version>5.1.1</Version> <Version>5.2.0</Version>
</PackageReference> </PackageReference>
<PackageReference Include="QueryString.NET"> <PackageReference Include="QueryString.NET">
<Version>1.0.0</Version> <Version>1.0.0</Version>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册