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

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

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

* 修复PGC内容播放问题
上级 e5f05aed
......@@ -1330,7 +1330,7 @@
<Version>2.8.2-prerelease.220830001</Version>
</PackageReference>
<PackageReference Include="Newtonsoft.Json">
<Version>13.0.2</Version>
<Version>13.0.3</Version>
</PackageReference>
<PackageReference Include="Richasy.FluentIcon.Regular.UWP">
<Version>1.1.150</Version>
......
<MPD xmlns="urn:mpeg:DASH:schema:MPD:2011" profiles="urn:mpeg:dash:profile:isoff-on-demand:2011" type="static"
minBufferTime="{bufferTime}">
<MPD xmlns="urn:mpeg:DASH:schema:MPD:2011" profiles="urn:mpeg:dash:profile:isoff-on-demand:2011" type="static">
<Period start="PT0S">
<AdaptationSet group="1">
<ContentComponent contentType="audio" id="1" />
{audio}
</AdaptationSet>
<AdaptationSet group="2">
<ContentComponent contentType="video" id="2" />
<AdaptationSet>
<ContentComponent contentType="video" id="1" />
{video}
</AdaptationSet>
<AdaptationSet>
<ContentComponent contentType="audio" id="2" />
{audio}
</AdaptationSet>
</Period>
</MPD>
<MPD xmlns="urn:mpeg:DASH:schema:MPD:2011" profiles="urn:mpeg:dash:profile:isoff-on-demand:2011" type="static"
minBufferTime="{bufferTime}">
<MPD xmlns="urn:mpeg:DASH:schema:MPD:2011" profiles="urn:mpeg:dash:profile:isoff-on-demand:2011" type="static">
<Period start="PT0S">
<AdaptationSet group="1">
<AdaptationSet>
<ContentComponent contentType="video" id="1" />
{video}
</AdaptationSet>
......
......@@ -129,7 +129,7 @@
<Version>6.2.14</Version>
</PackageReference>
<PackageReference Include="NLog">
<Version>5.1.1</Version>
<Version>5.2.0</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
......
......@@ -8,7 +8,7 @@
<ItemGroup>
<PackageReference Include="Autofac" Version="7.0.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.1.0" />
<PackageReference Include="NLog" Version="5.1.3" />
<PackageReference Include="NLog" Version="5.2.0" />
</ItemGroup>
</Project>
......@@ -135,7 +135,7 @@
<Version>6.2.14</Version>
</PackageReference>
<PackageReference Include="Newtonsoft.Json">
<Version>13.0.2</Version>
<Version>13.0.3</Version>
</PackageReference>
<PackageReference Include="Win2D.uwp">
<Version>1.26.0</Version>
......
......@@ -80,6 +80,7 @@ namespace Bili.Lib
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<string, string>
{
......@@ -113,7 +114,7 @@ namespace Bili.Lib
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<ServerResponse<PlayerInformation>, ServerResponse2<PlayerInformation>>(response, (str) =>
{
......
......@@ -333,7 +333,7 @@ namespace Bili.Lib
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 result = await _httpProvider.ParseAsync<SubtitleDetailResponse>(response);
return result.Body.Select(p => _playerAdapter.ConvertToSubtitleInformation(p)).ToList();
......
......@@ -32,7 +32,8 @@ namespace Bili.Models.Data.Player
int width,
int height,
string initialization,
string indexRange)
string indexRange,
int startWithSap = 1)
{
Id = id;
BaseUrl = baseUrl;
......@@ -44,6 +45,7 @@ namespace Bili.Models.Data.Player
Height = height;
Initialization = initialization;
IndexRange = indexRange;
StartWithSap = startWithSap;
}
/// <summary>
......@@ -96,6 +98,11 @@ namespace Bili.Models.Data.Player
/// </summary>
public string IndexRange { get; }
/// <summary>
/// None.
/// </summary>
public int StartWithSap { get; }
/// <inheritdoc/>
public override bool Equals(object obj) => obj is SegmentInformation information && Id == information.Id;
......
......@@ -29,7 +29,7 @@
<Version>6.2.14</Version>
</PackageReference>
<PackageReference Include="Newtonsoft.Json">
<Version>13.0.2</Version>
<Version>13.0.3</Version>
</PackageReference>
<PackageReference Include="ToolGood.Words">
<Version>3.0.3.1</Version>
......
......@@ -23,7 +23,7 @@ namespace Bili.ViewModels.Uwp.Core
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 @@ namespace Bili.ViewModels.Uwp.Core
var mpdStr = await _fileToolkit.ReadPackageFile(mpdFilePath);
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>
<SegmentBase indexRange=""{_video.IndexRange}"">
<Initialization range=""{_video.Initialization}"" />
......@@ -65,6 +65,7 @@ namespace Bili.ViewModels.Uwp.Core
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) =>
{
......
......@@ -222,7 +222,7 @@
<Version>7.1.3</Version>
</PackageReference>
<PackageReference Include="NLog">
<Version>5.1.1</Version>
<Version>5.2.0</Version>
</PackageReference>
<PackageReference Include="QueryString.NET">
<Version>1.0.0</Version>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册