Skip to content

Commit c450849

Browse files
committed
doc: 增加打开设备逻辑
1 parent 62d32b5 commit c450849

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ private IBluetooth? BluetoothService { get; set; }</Pre>
1414
<div class="row form-inline g-3">
1515
<div class="col-12">
1616
<Button Text="@Localizer["VideoDeviceRequestText"]" Icon="fa-solid fa-photo-film" OnClick="OnRequestDevice"></Button>
17-
<Button Text="@Localizer["VideoDeviceOpenText"]" Icon="fa-solid fa-play" OnClick="OnOpenVideo" class="ms-2"></Button>
18-
<Button Text="@Localizer["VideoDeviceCloseText"]" Icon="fa-solid fa-stop" OnClick="OnCloseVideo" class="ms-2"></Button>
19-
<Button Text="@Localizer["VideoDeviceCaptureText"]" Icon="fa-solid fa-camera" OnClick="OnCapture" class="ms-2"></Button>
17+
<Button Text="@Localizer["VideoDeviceOpenText"]" Icon="fa-solid fa-play" OnClick="OnOpenVideo" IsDisabled="_isOpen" class="ms-2"></Button>
18+
<Button Text="@Localizer["VideoDeviceCloseText"]" Icon="fa-solid fa-stop" OnClick="OnCloseVideo" IsDisabled="!_isOpen" class="ms-2"></Button>
19+
<Button Text="@Localizer["VideoDeviceCaptureText"]" Icon="fa-solid fa-camera" OnClick="OnCapture" IsDisabled="!_isOpen" class="ms-2"></Button>
2020
</div>
2121
<div class="col-12">
2222
<Select Items="@_items" @bind-Value="_deviceId" DisplayText="Devices" ShowLabel="true"></Select>

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ public partial class VideoDevices
2121

2222
private string? _previewUrl;
2323

24+
private bool _isOpen = false;
25+
2426
private async Task OnRequestDevice()
2527
{
2628
var devices = await VideoDeviceService.GetDevices();
@@ -41,7 +43,7 @@ private async Task OnOpenVideo()
4143
DeviceId = _deviceId,
4244
VideoSelector = ".bb-video"
4345
};
44-
await VideoDeviceService.Open(constraints);
46+
_isOpen = await VideoDeviceService.Open(constraints);
4547
}
4648
}
4749

0 commit comments

Comments
 (0)