!3625 doc(#I66EIA): update document for VideoPlayer component

* doc: 更新文档
* doc: 格式化文档
* chore: 格式化代码
* Merge remote-tracking branch 'origin/main' into fixed#I66EIA
* Merge branch 'doc/player' into fixed#I66EIA
* feat(#I66EIA): fixed VideoPlayer components doc of attributes error
* doc: 菜单排序
* refactor: 重构代码
This commit is contained in:
alex_zou 2022-12-16 02:18:40 +00:00 committed by Argo
parent 888588114e
commit f47f14afef
4 changed files with 65 additions and 72 deletions

View File

@ -7,7 +7,6 @@ using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.AspNetCore.SignalR;
using Microsoft.AspNetCore.StaticFiles;
using Microsoft.Extensions.Options;
using Microsoft.Net.Http.Headers;
using System.Text;
var builder = WebApplication.CreateBuilder(args);
@ -46,7 +45,7 @@ if (option != null)
}
// 启用转发中间件
app.UseForwardedHeaders(new ForwardedHeadersOptions() { ForwardedHeaders = ForwardedHeaders.All });
app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.All });
if (app.Environment.IsDevelopment())
{
@ -59,12 +58,10 @@ else
app.UseStaticFiles(new StaticFileOptions { OnPrepareResponse = ctx => ctx.ProcessCache(app.Configuration) });
}
var provider = new FileExtensionContentTypeProvider {Mappings = {[".properties"] = "application/octet-stream"}};
var provider = new FileExtensionContentTypeProvider();
provider.Mappings[".properties"] = "application/octet-stream";
app.UseStaticFiles(new StaticFileOptions
{
ContentTypeProvider = provider
});
app.UseStaticFiles(new StaticFileOptions { ContentTypeProvider = provider });
app.UseStaticFiles();
app.UseRouting();

View File

@ -403,6 +403,12 @@ internal static class MenusLocalizerExtensions
Url = "blocks"
},
new()
{
IsNew = true,
Text = Localizer["Bluetooth"],
Url = "bluetooths"
},
new()
{
Text = Localizer["Card"],
Url = "cards"
@ -504,6 +510,12 @@ internal static class MenusLocalizerExtensions
Url = "imageviewers"
},
new()
{
IsNew = true,
Text = Localizer["PdfReader"],
Url = "PdfReaders"
},
new()
{
Text = Localizer["Print"],
Url = "prints"
@ -576,18 +588,6 @@ internal static class MenusLocalizerExtensions
Url = "transitions"
},
new()
{
IsNew = true,
Text = Localizer["Bluetooth"],
Url = "bluetooths"
},
new()
{
IsNew = true,
Text = Localizer["PdfReader"],
Url = "PdfReaders"
},
new()
{
IsNew = true,
Text = Localizer["VideoPlayer"],

View File

@ -53,7 +53,7 @@
</div>
</div>
<br />
<VideoPlayer @ref="video1" SourcesType="@SourcesType" SourcesUrl="@SourcesUrl" Width="500" Height="380" />
<VideoPlayer @ref="Player" SourcesType="@SourcesType" SourcesUrl="@SourcesUrl" Width="500" Height="380" />
</DemoBlock>

View File

@ -2,9 +2,6 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/
using BootstrapBlazor.Components;
using BootstrapBlazor.Shared.Common;
namespace BootstrapBlazor.Shared.Samples;
/// <summary>
@ -15,9 +12,10 @@ public partial class VideoPlayers
private string SourcesType = "video/mp4";
private string SourcesUrl = "//vjs.zencdn.net/v/oceans.mp4";
VideoPlayer? video1;
[NotNull]
private VideoPlayer? Player { get; set; }
List<string> VideoList = new List<string>
private List<string> VideoList { get; } = new()
{
"https://rtvelivestream.akamaized.net/rtvesec/la1/la1_main.m3u8",
"https://d2zihajmogu5jn.cloudfront.net/bipbop-advanced/bipbop_16x9_variant.m3u8",
@ -27,11 +25,10 @@ public partial class VideoPlayers
"https://moctobpltc-i.akamaihd.net/hls/live/571329/eight/playlist.m3u8",
"https://cph-p2p-msl.akamaized.net/hls/live/2000341/test/master.m3u8",
"https://demo.unified-streaming.com/k8s/features/stable/video/tears-of-steel/tears-of-steel.mp4/.m3u8",
"https://diceyk6a7voy4.cloudfront.net/e78752a1-2e83-43fa-85ae-3d508be29366/hls/fitfest-sample-1_Ott_Hls_Ts_Avc_Aac_16x9_1280x720p_30Hz_6.0Mbps_qvbr.m3u8",
"https://diceyk6a7voy4.cloudfront.net/e78752a1-2e83-43fa-85ae-3d508be29366/hls/fitfest-sample-1_Ott_Hls_Ts_Avc_Aac_16x9_1280x720p_30Hz_6.0Mbps_qvbr.m3u8"
};
List<SelectedItem> Items = new List<SelectedItem>();
private List<SelectedItem> Items { get; } = new();
/// <summary>
/// OnInitialized 方法
@ -39,7 +36,7 @@ public partial class VideoPlayers
protected override void OnInitialized()
{
base.OnInitialized();
for (int i = 0; i < VideoList.Count; i++)
for (var i = 0; i < VideoList.Count; i++)
{
Items.Add(new SelectedItem { Text = $"TestVideo{i}", Value = VideoList[i] });
}
@ -56,94 +53,93 @@ public partial class VideoPlayers
private async Task Apply()
{
await video1.SetPoster("//vjs.zencdn.net/v/oceans.png");
await video1.Reload(SourcesUrl, SourcesType);
await Player.SetPoster("//vjs.zencdn.net/v/oceans.png");
await Player.Reload(SourcesUrl, SourcesType);
}
/// <summary>
/// 获得属性方法
/// </summary>
/// <returns></returns>
protected IEnumerable<AttributeItem> GetAttributes() => new AttributeItem[]
private IEnumerable<AttributeItem> GetAttributes() => new AttributeItem[]
{
// TODO: 移动到数据库中
new AttributeItem() {
Name = "SourcesUrl",
new() {
Name = nameof(VideoPlayer.SourcesUrl),
Description = "资源地址",
Type = "Stream?",
ValueList = "-",
DefaultValue = "null"
Type = "string?",
ValueList = "",
DefaultValue = ""
},
new AttributeItem() {
Name = "SourcesType",
new() {
Name = nameof(VideoPlayer.SourcesType),
Description = "资源类型,video/mp4, application/x-mpegURL, video/ogg .. ",
Type = "string?",
ValueList = "-",
ValueList = "(见页脚)",
DefaultValue = "application/x-mpegURL"
},
new AttributeItem() {
Name = "Width",
new() {
Name = nameof(VideoPlayer.Width),
Description = "宽度",
Type = "int",
ValueList = "-",
ValueList = "",
DefaultValue = "300"
},
new AttributeItem() {
Name = "Height",
new() {
Name = nameof(VideoPlayer.Height),
Description = "高度",
Type = "int",
ValueList = "-",
ValueList = "",
DefaultValue = "200"
},
new AttributeItem() {
Name = "Controls",
new() {
Name = nameof(VideoPlayer.Controls),
Description = "显示控制条",
Type = "bool",
ValueList = "-",
ValueList = "true|false",
DefaultValue = "true"
},
new AttributeItem() {
Name = "Autoplay",
new() {
Name = nameof(VideoPlayer.Autoplay),
Description = "自动播放",
Type = "bool",
ValueList = "-",
ValueList = "true|false",
DefaultValue = "true"
},
new AttributeItem() {
Name = "Poster",
new() {
Name = nameof(VideoPlayer.Poster),
Description = "设置封面资源,相对或者绝对路径",
Type = "bool",
ValueList = "string?",
DefaultValue = "true"
Type = "string?",
ValueList = "",
DefaultValue = ""
},
new AttributeItem() {
Name = "Option",
new() {
Name = nameof(VideoPlayer.Option),
Description = "播放器选项, 不为空则优先使用播放器选项,否则使用参数构建",
Type = "VideoPlayerOption",
ValueList = "-",
DefaultValue = "null"
ValueList = "",
DefaultValue = ""
},
new AttributeItem() {
new() {
Name = "Reload(string? url, string? type)",
Description = "切换播放资源",
Type = "async Task",
ValueList = "-",
DefaultValue = "-"
ValueList = "",
DefaultValue = ""
},
new AttributeItem() {
new() {
Name = "SetPoster(string? poster)",
Description = "设置封面",
Type = "async Task",
ValueList = "-",
DefaultValue = "-"
ValueList = "",
DefaultValue = ""
},
new AttributeItem() {
new() {
Name = "OnError",
Description = "错误回调",
Type = "Func<string, Task>??",
ValueList = "-",
DefaultValue = "-"
ValueList = "",
DefaultValue = ""
},
};
};
}