Skip to content

Commit bed84ac

Browse files
authored
feat(HikVision): add StartRecord/StopRecord function (#7410)
* feat(HikVision): add StartRecord/StopRecord function * chore: bump vesion 10.0.7
1 parent 32aebe2 commit bed84ac

3 files changed

Lines changed: 49 additions & 2 deletions

File tree

src/BootstrapBlazor.Server/BootstrapBlazor.Server.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<PackageReference Include="BootstrapBlazor.FluentSystemIcon" Version="10.0.0" />
4343
<PackageReference Include="BootstrapBlazor.FontAwesome" Version="10.0.0" />
4444
<PackageReference Include="BootstrapBlazor.Gantt" Version="10.0.0" />
45-
<PackageReference Include="BootstrapBlazor.HikVision" Version="10.0.6" />
45+
<PackageReference Include="BootstrapBlazor.HikVision" Version="10.0.7" />
4646
<PackageReference Include="BootstrapBlazor.Holiday" Version="10.0.0" />
4747
<PackageReference Include="BootstrapBlazor.Html2Image" Version="10.0.0" />
4848
<PackageReference Include="BootstrapBlazor.Html2Pdf" Version="10.0.1" />

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,17 @@
1313

1414
<DemoBlock Title="@Localizer["BasicUsageTitle"]" Introduction="@Localizer["BasicUsageIntro"]" Name="Normal">
1515
<section ignore>
16-
<p>注意事项:</p>
16+
<p class="code-label">注意事项:</p>
1717
<ul class="ul-demo">
1818
<li><code>HikVisionWebPlugin</code> 组件依赖海康威视 Web 插件包,仅支持 windows 平台</li>
1919
<li>由于核心功能均由海康威视 Web 插件提供所有浏览器控制台中会有部分提示或者报错信息均属于正常现象</li>
2020
<li>由海康威视 Web 插件绘制的预览窗口并不是 html dom 元素,所以出现被截断遮挡其他窗口,多屏显示不正确时请刷新浏览器即可</li>
2121
</ul>
22+
<p class="code-label">录像功能说明:</p>
23+
<ul class="ul-demo">
24+
<li>必须登录并且开始预览后才可以开启录像功能</li>
25+
<li>开始录像后,文件默认存储在插件安装路径文件夹内(C:\Users\[UserName]\HCWebSDKPlugins\RecordFiles)</li>
26+
</ul>
2227
</section>
2328
<HikVisionWebPlugin @ref="_hikVision" OnInitedAsync="OnInitedAsync"
2429
OnLoginAsync="OnLoginAsync" OnLogoutAsync="OnLogoutAsync" OnGetChannelsAsync="OnGetChannelsAsync"
@@ -85,6 +90,12 @@
8590
<Button OnClick="OnCapture" IsDisabled="_stopRealPlayStatus">
8691
<span>抓图</span>
8792
</Button>
93+
<Button OnClick="OnStartRecord" IsDisabled="_startRecordStatus">
94+
<span>开始录像</span>
95+
</Button>
96+
<Button OnClick="OnStopRecord" IsDisabled="_stopRecordStatus">
97+
<span>停止录像</span>
98+
</Button>
8899
</div>
89100
}
90101
</div>

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ public partial class HikVisions
3232
private bool _stopRealPlayStatus = true;
3333
private bool _openSoundStatus = true;
3434
private bool _closeSoundStatus = true;
35+
private bool _startRecordStatus = true;
36+
private bool _stopRecordStatus = true;
3537

3638
private List<SelectedItem> _analogChannels = [];
3739
private int _channelId = 1;
@@ -114,6 +116,36 @@ private async Task OnCapture()
114116
await _hikVision.CapturePictureAndDownload();
115117
}
116118

119+
private async Task OnStartRecord()
120+
{
121+
var result = await _hikVision.StartRecord();
122+
if (result)
123+
{
124+
_startRecordStatus = true;
125+
_stopRecordStatus = false;
126+
await ToastService.Success("消息通知", "开始录像成功");
127+
}
128+
else
129+
{
130+
await ToastService.Error("消息通知", "开始录像失败");
131+
}
132+
}
133+
134+
private async Task OnStopRecord()
135+
{
136+
var result = await _hikVision.StopRecord();
137+
if (result)
138+
{
139+
_startRecordStatus = false;
140+
_stopRecordStatus = true;
141+
await ToastService.Success("消息通知", "结束录像成功");
142+
}
143+
else
144+
{
145+
await ToastService.Error("消息通知", "结束录像失败");
146+
}
147+
}
148+
117149
private async Task OnInitedAsync(bool initialized)
118150
{
119151
_inited = initialized;
@@ -181,6 +213,8 @@ private Task OnStartRealPlayedAsync()
181213
_stopRealPlayStatus = !_startRealPlayStatus;
182214
_openSoundStatus = false;
183215
_closeSoundStatus = true;
216+
_startRecordStatus = false;
217+
_stopRecordStatus = true;
184218
StateHasChanged();
185219
return Task.CompletedTask;
186220
}
@@ -191,6 +225,8 @@ private Task OnStopRealPlayedAsync()
191225
_stopRealPlayStatus = !_startRealPlayStatus;
192226
_openSoundStatus = true;
193227
_closeSoundStatus = true;
228+
_startRecordStatus = true;
229+
_stopRecordStatus = true;
194230
StateHasChanged();
195231
return Task.CompletedTask;
196232
}

0 commit comments

Comments
 (0)