Skip to content

Commit 61871f2

Browse files
authored
feat(HikVision): add OpenSound/CloseSound method (#7404)
* feat(HikVision): add OpenSound/CloseSound method * doc: 更新示例 * doc: 更新示例
1 parent 30c29bb commit 61871f2

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

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.4" />
45+
<PackageReference Include="BootstrapBlazor.HikVision" Version="10.0.5" />
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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@
7676
<Button OnClick="OnStopRealPlay" IsDisabled="_stopRealPlayStatus">
7777
<span>停止预览</span>
7878
</Button>
79+
<Button OnClick="OnOpenSound" IsDisabled="_openSoundStatus">
80+
<span>打开声音</span>
81+
</Button>
82+
<Button OnClick="OnCloseSound" IsDisabled="_closeSoundStatus">
83+
<span>关闭声音</span>
84+
</Button>
7985
</div>
8086
}
8187
</div>

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

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ public partial class HikVisions
1515
[Inject, NotNull]
1616
private SwalService? SwalService { get; set; }
1717

18+
[Inject, NotNull]
19+
private ToastService? ToastService { get; set; }
20+
1821
private HikVisionWebPlugin _hikVision = default!;
1922

2023
private string _ip = "47.121.113.151";
@@ -27,6 +30,8 @@ public partial class HikVisions
2730
private bool _logoutStatus = true;
2831
private bool _startRealPlayStatus = true;
2932
private bool _stopRealPlayStatus = true;
33+
private bool _openSoundStatus = true;
34+
private bool _closeSoundStatus = true;
3035

3136
private List<SelectedItem> _analogChannels = [];
3237
private int _channelId = 1;
@@ -53,23 +58,59 @@ private async Task OnLogout()
5358
_logoutStatus = true;
5459
_startRealPlayStatus = true;
5560
_stopRealPlayStatus = true;
61+
_openSoundStatus = true;
62+
_closeSoundStatus = true;
5663
await _hikVision.Logout();
5764
}
5865

5966
private async Task OnStartRealPlay()
6067
{
6168
_startRealPlayStatus = true;
6269
_stopRealPlayStatus = true;
70+
_openSoundStatus = false;
71+
_closeSoundStatus = true;
6372
await _hikVision.StartRealPlay(_streamType, _channelId);
6473
}
6574

6675
private async Task OnStopRealPlay()
6776
{
6877
_startRealPlayStatus = true;
6978
_stopRealPlayStatus = true;
79+
_openSoundStatus = true;
80+
_closeSoundStatus = true;
7081
await _hikVision.StopRealPlay();
7182
}
7283

84+
private async Task OnOpenSound()
85+
{
86+
var result = await _hikVision.OpenSound();
87+
if (result)
88+
{
89+
_openSoundStatus = true;
90+
_closeSoundStatus = false;
91+
await ToastService.Success("消息通知", "打开声音成功");
92+
}
93+
else
94+
{
95+
await ToastService.Error("消息通知", "打开声音失败");
96+
}
97+
}
98+
99+
private async Task OnCloseSound()
100+
{
101+
var result = await _hikVision.CloseSound();
102+
if (result)
103+
{
104+
_openSoundStatus = false;
105+
_closeSoundStatus = true;
106+
await ToastService.Success("消息通知", "关闭声音成功");
107+
}
108+
else
109+
{
110+
await ToastService.Error("消息通知", "关闭声音失败");
111+
}
112+
}
113+
73114
private async Task OnInitedAsync(bool initialized)
74115
{
75116
_inited = initialized;

0 commit comments

Comments
 (0)