@@ -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