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

Commit

Permalink
修复PGC内容无法播放以及自动生成字幕未显示的问题 (#1705)
Browse files Browse the repository at this point in the history
* 修复自动生成的字幕没有显示的问题

* 修复PGC内容播放问题
  • Loading branch information
Richasy authored Jun 2, 2023
1 parent e5f05ae commit deee4e6
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/App/App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
15 changes: 7 additions & 8 deletions src/App/Assets/DashVideoTemplate.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<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>
5 changes: 2 additions & 3 deletions src/App/Assets/DashVideoWithoutAudioTemplate.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<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>
Expand Down
2 changes: 1 addition & 1 deletion src/Lib/DI.App/DI.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion src/Lib/DI.Container/DI.Container.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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>
2 changes: 1 addition & 1 deletion src/Lib/FrostMaster.Uwp/FrostMaster.Uwp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ private async Task<MediaInformation> 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<string, string>
{
Expand Down Expand Up @@ -113,7 +114,7 @@ private async Task<MediaInformation> 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<ServerResponse<PlayerInformation>, ServerResponse2<PlayerInformation>>(response, (str) =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ public async Task<IEnumerable<SubtitleInformation>> GetSubtitleDetailAsync(strin
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();
Expand Down
9 changes: 8 additions & 1 deletion src/Models/Models.Data/Player/SegmentInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ public SegmentInformation(
int width,
int height,
string initialization,
string indexRange)
string indexRange,
int startWithSap = 1)
{
Id = id;
BaseUrl = baseUrl;
Expand All @@ -44,6 +45,7 @@ public SegmentInformation(
Height = height;
Initialization = initialization;
IndexRange = indexRange;
StartWithSap = startWithSap;
}

/// <summary>
Expand Down Expand Up @@ -96,6 +98,11 @@ public SegmentInformation(
/// </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;

Expand Down
2 changes: 1 addition & 1 deletion src/Utilities/Toolkit/Toolkit.Uwp/Toolkit.Uwp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -37,7 +37,7 @@ private async Task LoadDashVideoSourceAsync()
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}"" />
Expand Down Expand Up @@ -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) =>
{
Expand Down
2 changes: 1 addition & 1 deletion src/ViewModels/ViewModels.Uwp/ViewModels.Uwp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit deee4e6

Please sign in to comment.