-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathPlayer.razor.cs
More file actions
69 lines (60 loc) · 1.92 KB
/
Player.razor.cs
File metadata and controls
69 lines (60 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// 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 Microsoft.AspNetCore.Components;
using System.Globalization;
namespace BootstrapBlazor.Components;
/// <summary>
/// 视频播放器 Player 组件
/// </summary>
public partial class Player
{
/// <summary>
/// 获得/设置 组件模式 默认为 <see cref="PlayerMode.Video"/>
/// </summary>
[Parameter]
public PlayerMode Mode { get; set; }
/// <summary>
/// 获得/设置 PlayerOption 实例
/// </summary>
[Parameter]
[EditorRequired]
public PlayerOptions? Options { get; set; }
/// <summary>
/// Gets or sets the client event callback. Default is null.
/// </summary>
[Parameter]
public Func<string, Task>? OnEvent { get; set; }
private string? EventString => OnEvent == null ? "true" : null;
/// <summary>
/// <inheritdoc/>
/// </summary>
/// <returns></returns>
protected override async Task InvokeInitAsync()
{
if (Options != null)
{
Options.Language ??= CultureInfo.CurrentUICulture.Name;
}
await InvokeVoidAsync("init", Id, Interop, nameof(TriggerEvent), Options);
}
/// <summary>
/// 重新配置播放器方法
/// </summary>
/// <param name="option"></param>
/// <returns></returns>
public Task Reload(PlayerOptions option) => InvokeVoidAsync("reload", Id, option);
/// <summary>
/// Trigger <see cref="OnEvent"/> event callback. Triggered by JSInterop.
/// </summary>
/// <param name="eventName"></param>
/// <returns></returns>
[JSInvokable]
public async Task TriggerEvent(string eventName)
{
if (OnEvent != null)
{
await OnEvent(eventName);
}
}
}