File tree Expand file tree Collapse file tree 4 files changed +29
-12
lines changed
src/BootstrapBlazor/Services/MediaDevices Expand file tree Collapse file tree 4 files changed +29
-12
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,18 @@ public async Task Capture()
4545 return await module . InvokeAsync < string ? > ( "getPreviewUrl" ) ;
4646 }
4747
48+ public async Task < Stream ? > GetPreviewData ( )
49+ {
50+ Stream ? ret = null ;
51+ var module = await LoadModule ( ) ;
52+ var stream = await module . InvokeAsync < IJSStreamReference ? > ( "getPreviewData" ) ;
53+ if ( stream != null )
54+ {
55+ ret = await stream . OpenReadStreamAsync ( stream . Length ) ;
56+ }
57+ return ret ;
58+ }
59+
4860 public async Task < bool > Apply ( MediaTrackConstraints constraints )
4961 {
5062 var module = await LoadModule ( ) ;
Original file line number Diff line number Diff line change @@ -37,6 +37,11 @@ public Task Capture()
3737 return deviceService . Capture ( ) ;
3838 }
3939
40+ public Task < Stream ? > GetPreviewData ( )
41+ {
42+ return deviceService . GetPreviewData ( ) ;
43+ }
44+
4045 public Task < string ? > GetPreviewUrl ( )
4146 {
4247 return deviceService . GetPreviewUrl ( ) ;
Original file line number Diff line number Diff line change @@ -43,6 +43,12 @@ public interface IMediaDevices
4343 /// <returns></returns>
4444 Task < string ? > GetPreviewUrl ( ) ;
4545
46+ /// <summary>
47+ /// Gets the stream of the captured image.
48+ /// </summary>
49+ /// <returns></returns>
50+ Task < Stream ? > GetPreviewData ( ) ;
51+
4652 /// <summary>
4753 /// Apply the media track constraints.
4854 /// </summary>
Original file line number Diff line number Diff line change @@ -36,24 +36,18 @@ public interface IVideoDevice
3636 /// <returns></returns>
3737 Task Capture ( ) ;
3838
39- ///// <summary>
40- ///// Preview a still image from the video stream.
41- ///// </summary>
42- ///// <returns></returns>
43- //Task Preview();
44-
45- ///// <summary>
46- ///// Gets the stream of the captured image.
47- ///// </summary>
48- ///// <returns></returns>
49- //Task<Stream?> GetPreviewImage();
50-
5139 /// <summary>
5240 /// Gets the preview URL of the captured image.
5341 /// </summary>
5442 /// <returns></returns>
5543 Task < string ? > GetPreviewUrl ( ) ;
5644
45+ /// <summary>
46+ /// Gets the stream of the captured image.
47+ /// </summary>
48+ /// <returns></returns>
49+ Task < Stream ? > GetPreviewData ( ) ;
50+
5751 /// <summary>
5852 /// Apply the media track constraints.
5953 /// </summary>
You can’t perform that action at this time.
0 commit comments