@@ -410,17 +410,19 @@ export async function setVolume(id, value) {
410410}
411411
412412export async function capturePicture ( id ) {
413- const vision = Data . get ( id ) ;
414- const { iWndIndex , realPlaying, invoke } = vision ;
413+ const vision = Data . get ( id ) ;
414+ const { realPlaying } = vision ;
415415
416416 if ( realPlaying !== true ) {
417417 return "" ;
418418 }
419419
420420 try {
421421 const base64 = await WebVideoCtrl . I_CapturePicData ( ) ;
422- const bytes = base64ToArray ( base64 ) ;
423- return DotNet . createJSStreamReference ( bytes . buffer ) ;
422+ if ( base64 ) {
423+ const bytes = base64ToArray ( base64 ) ;
424+ return DotNet . createJSStreamReference ( bytes . buffer ) ;
425+ }
424426 }
425427 catch ( ex ) {
426428 return null ;
@@ -440,21 +442,27 @@ const base64ToArray = base64String => {
440442 return bytes ;
441443}
442444
443- export function capturePictureAndDownload ( id ) {
445+ export async function capturePictureAndDownload ( id ) {
444446 const vision = Data . get ( id ) ;
445- const { iWndIndex , realPlaying, invoke } = vision ;
447+ const { realPlaying } = vision ;
446448
447449 if ( realPlaying !== true ) {
448- return "" ;
450+ return ;
449451 }
450452
451453 try {
452454 const base64 = await WebVideoCtrl . I_CapturePicData ( ) ;
453- const bytes = base64ToArray ( base64 ) ;
454- return DotNet . createJSStreamReference ( bytes . buffer ) ;
455+ if ( base64 ) {
456+ const anchorElement = document . createElement ( 'a' ) ;
457+ anchorElement . href = `data:image/jpg;base64,${ base64 } ` ;
458+ anchorElement . download = `capture_${ new Date ( ) . getTime ( ) } .jpg` ;
459+ document . body . appendChild ( anchorElement ) ;
460+ anchorElement . click ( ) ;
461+ document . body . removeChild ( anchorElement ) ;
462+ }
455463 }
456464 catch ( ex ) {
457- return null ;
465+
458466 }
459467}
460468
0 commit comments