Skip to content

Commit 00f1cf1

Browse files
committed
doc: 增加自动关闭视频逻辑
1 parent 0471602 commit 00f1cf1

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/BootstrapBlazor.Server/Components/Samples/VideoDevices.razor.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace BootstrapBlazor.Server.Components.Samples;
88
/// <summary>
99
/// VideoDevice Component
1010
/// </summary>
11-
public partial class VideoDevices
11+
public partial class VideoDevices : IAsyncDisposable
1212
{
1313
[Inject, NotNull]
1414
private IVideoDevice? VideoDeviceService { get; set; }
@@ -60,4 +60,23 @@ private async Task OnCapture()
6060
{
6161
_previewUrl = await VideoDeviceService.GetPreviewUrl();
6262
}
63+
64+
private async Task DisposeAsync(bool disposing)
65+
{
66+
if (disposing)
67+
{
68+
await OnCloseVideo();
69+
}
70+
}
71+
72+
/// <summary>
73+
/// <inheritdoc/>
74+
/// </summary>
75+
/// <returns></returns>
76+
/// <exception cref="NotImplementedException"></exception>
77+
public async ValueTask DisposeAsync()
78+
{
79+
await DisposeAsync(true);
80+
GC.SuppressFinalize(this);
81+
}
6382
}

0 commit comments

Comments
 (0)