Skip to content

Commit ac070e8

Browse files
committed
feat: 增加抓图并下载功能
1 parent 1015de5 commit ac070e8

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

src/components/BootstrapBlazor.HikVision/Components/HikVisionWebPlugin.razor.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,18 @@ public async Task<bool> SetVolume(int value)
316316
return ret;
317317
}
318318

319+
/// <summary>
320+
/// 抓图方法返回 Url
321+
/// </summary>
322+
/// <returns></returns>
323+
public async Task CapturePictureAndDownload()
324+
{
325+
if (IsLogin && IsRealPlaying)
326+
{
327+
var stream = await InvokeAsync<IJSStreamReference?>("capturePictureAndDownload", Id);
328+
}
329+
}
330+
319331
private TaskCompletionSource<IJSStreamReference?>? _captureTaskCompletionSource = null;
320332

321333
/// <summary>

src/components/BootstrapBlazor.HikVision/wwwroot/hikvision.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,25 @@ const base64ToArray = base64String => {
439439

440440
return bytes;
441441
}
442+
443+
export function capturePictureAndDownload(id) {
444+
const vision = Data.get(id);
445+
const { iWndIndex, realPlaying, invoke } = vision;
446+
447+
if (realPlaying !== true) {
448+
return "";
449+
}
450+
451+
try {
452+
const base64 = await WebVideoCtrl.I_CapturePicData();
453+
const bytes = base64ToArray(base64);
454+
return DotNet.createJSStreamReference(bytes.buffer);
455+
}
456+
catch (ex) {
457+
return null;
458+
}
459+
}
460+
442461
export function dispose(id) {
443462
const vision = Data.get(id);
444463
const { realPlaying, logined, observer } = vision;

0 commit comments

Comments
 (0)