@@ -115,6 +115,16 @@ public partial class HikVisionWebPlugin
115115 /// </summary>
116116 public bool IsRealPlaying { get ; private set ; }
117117
118+ /// <summary>
119+ /// 获得 是否已经打开声音
120+ /// </summary>
121+ public bool IsOpenSound { get ; private set ; }
122+
123+ /// <summary>
124+ /// 获得 是否开始录像
125+ /// </summary>
126+ public bool IsStartRecord { get ; private set ; }
127+
118128 /// <summary>
119129 /// <inheritdoc/>
120130 /// </summary>
@@ -164,6 +174,7 @@ public async Task Logout()
164174 {
165175 await InvokeVoidAsync ( "logout" , Id ) ;
166176 }
177+ IsStartRecord = false ;
167178 IsRealPlaying = false ;
168179 IsLogin = false ;
169180 await TriggerLogout ( ) ;
@@ -221,6 +232,7 @@ public async Task StopRealPlay()
221232 {
222233 await InvokeVoidAsync ( "stopRealPlay" , Id ) ;
223234 IsRealPlaying = false ;
235+ IsStartRecord = false ;
224236 await TriggerStopRealPlay ( ) ;
225237 }
226238 }
@@ -281,6 +293,7 @@ public async Task<bool> OpenSound()
281293 {
282294 var code = await InvokeAsync < int > ( "openSound" , Id ) ;
283295 ret = code == 100 ;
296+ IsOpenSound = true ;
284297 }
285298 return ret ;
286299 }
@@ -296,6 +309,7 @@ public async Task<bool> CloseSound()
296309 {
297310 var code = await InvokeAsync < int > ( "closeSound" , Id ) ;
298311 ret = code == 100 ;
312+ IsOpenSound = false ;
299313 }
300314 return ret ;
301315 }
@@ -320,54 +334,30 @@ public async Task<bool> SetVolume(int value)
320334 /// 抓图方法并且下载方法
321335 /// </summary>
322336 /// <returns></returns>
323- public async Task CapturePictureAndDownload ( )
337+ public async Task < bool > CapturePictureAndDownload ( string ? fileName = null , CancellationToken token = default )
324338 {
339+ var ret = false ;
325340 if ( IsLogin && IsRealPlaying )
326341 {
327- await InvokeVoidAsync ( "capturePictureAndDownload" , Id ) ;
342+ ret = await InvokeAsync < bool > ( "capturePictureAndDownload" , token , Id , fileName ) ;
328343 }
344+ return ret ;
329345 }
330346
331- private TaskCompletionSource < IJSStreamReference ? > ? _captureTaskCompletionSource = null ;
332-
333347 /// <summary>
334348 /// 抓图方法返回 <see cref="IJSStreamReference"/> 实例
335349 /// </summary>
336350 /// <returns></returns>
337- public async Task < IJSStreamReference ? > CapturePicture ( CancellationToken token = default )
351+ public async Task < bool > CapturePicture ( string ? fileName = null , CancellationToken token = default )
338352 {
339- IJSStreamReference ? ret = null ;
353+ var ret = false ;
340354 if ( IsLogin && IsRealPlaying )
341355 {
342- _captureTaskCompletionSource = new ( ) ;
343-
344- try
345- {
346- await InvokeVoidAsync ( "capturePicture" , token , Id ) ;
347- ret = await _captureTaskCompletionSource . Task ;
348- }
349- catch ( Exception ex )
350- {
351- _captureTaskCompletionSource . SetException ( ex ) ;
352- }
356+ ret = await InvokeAsync < bool > ( "capturePicture" , token , Id , fileName ) ;
353357 }
354358 return ret ;
355359 }
356360
357- /// <summary>
358- /// 抓图返回文件流方法 由 Javascript 调用
359- /// </summary>
360- /// <param name="stream"></param>
361- /// <returns></returns>
362- [ JSInvokable ]
363- public async Task TriggerReceivePictureStream ( IJSStreamReference stream )
364- {
365- if ( _captureTaskCompletionSource != null )
366- {
367- _captureTaskCompletionSource . SetResult ( stream ) ;
368- }
369- }
370-
371361 /// <summary>
372362 /// 开始录像方法
373363 /// </summary>
@@ -378,6 +368,7 @@ public async Task<bool> StartRecord()
378368 if ( IsLogin && IsRealPlaying )
379369 {
380370 ret = await InvokeAsync < bool > ( "startRecord" , Id ) ;
371+ IsStartRecord = ret ;
381372 }
382373 return ret ;
383374 }
@@ -392,6 +383,10 @@ public async Task<bool> StopRecord()
392383 if ( IsLogin && IsRealPlaying )
393384 {
394385 ret = await InvokeAsync < bool > ( "stopRecord" , Id ) ;
386+ if ( ret )
387+ {
388+ IsStartRecord = false ;
389+ }
395390 }
396391 return ret ;
397392 }
0 commit comments