Skip to content

Commit 5e4ee67

Browse files
committed
refactor: 更改服务名称
1 parent 2299067 commit 5e4ee67

File tree

7 files changed

+18
-17
lines changed

7 files changed

+18
-17
lines changed

src/BootstrapBlazor.Server/Components/Samples/MediaDevice.razor.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace BootstrapBlazor.Server.Components.Samples;
1111
public partial class MediaDevice
1212
{
1313
[Inject, NotNull]
14-
private IMediaVideo? VideoDeviceService { get; set; }
14+
private IVideoDevice? MediaVideoService { get; set; }
1515

1616
private readonly List<IMediaDeviceInfo> _devices = [];
1717

@@ -21,7 +21,7 @@ public partial class MediaDevice
2121

2222
private async Task OnRequestDevice()
2323
{
24-
var devices = await VideoDeviceService.GetDevices();
24+
var devices = await MediaVideoService.GetDevices();
2525
if (devices != null)
2626
{
2727
_devices.AddRange(devices);
@@ -38,14 +38,13 @@ private async Task OnOpenVideo()
3838
DeviceId = _deviceId,
3939
VideoSelector = ".bb-video"
4040
};
41-
await VideoDeviceService.Open(constraints);
41+
await MediaVideoService.Open(constraints);
4242
}
4343
}
4444

4545
private async Task OnCloseVideo()
4646
{
47-
await Task.Delay(1);
48-
//await VideoDeviceService.Close(".bb-video");
47+
await MediaVideoService.Close(".bb-video");
4948
}
5049

5150
private async Task OnCapture()

src/BootstrapBlazor/Extensions/BootstrapBlazorServiceCollectionExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public static IServiceCollection AddBootstrapBlazor(this IServiceCollection serv
8787
services.TryAddScoped<ISerialService, DefaultSerialService>();
8888
services.TryAddScoped<IBluetooth, DefaultBluetooth>();
8989
services.TryAddScoped<IMediaDevices, DefaultMediaDevices>();
90-
services.TryAddScoped<IMediaVideo, DefaultMediaVideo>();
90+
services.TryAddScoped<IVideoDevice, DefaultVideoDevice>();
9191
services.AddScoped<TabItemTextOptions>();
9292
services.AddScoped<DialogService>();
9393
services.AddScoped<MaskService>();

src/BootstrapBlazor/Services/MediaDevices/DefaultMediaDevices.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ public async Task Open(MediaTrackConstraints constraints)
2929
await module.InvokeVoidAsync("open", constraints);
3030
}
3131

32-
public async Task Close()
32+
public async Task Close(string? videoSelector)
3333
{
3434
var module = await LoadModule();
35-
await module.InvokeVoidAsync("close", "");
35+
await module.InvokeVoidAsync("close", videoSelector);
3636
}
3737

3838
public async Task Capture()
3939
{
4040
var module = await LoadModule();
41-
await module.InvokeVoidAsync("capture", "");
41+
await module.InvokeVoidAsync("capture");
4242
}
4343
}

src/BootstrapBlazor/Services/MediaDevices/DefaultMediaVideo.cs renamed to src/BootstrapBlazor/Services/MediaDevices/DefaultVideoDevice.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace BootstrapBlazor.Components;
77

8-
class DefaultMediaVideo(IMediaDevices deviceService) : IMediaVideo
8+
class DefaultVideoDevice(IMediaDevices deviceService) : IVideoDevice
99
{
1010
/// <summary>
1111
/// <inheritdoc/>
@@ -27,9 +27,9 @@ public Task Open(MediaTrackConstraints constraints)
2727
return deviceService.Open(constraints);
2828
}
2929

30-
public Task Close()
30+
public Task Close(string? videoSelector)
3131
{
32-
return deviceService.Close();
32+
return deviceService.Close(videoSelector);
3333
}
3434

3535
public Task Capture()

src/BootstrapBlazor/Services/MediaDevices/IMediaDevices.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ public interface IMediaDevices
2626
/// <summary>
2727
/// The close() method of the MediaDevices interface stops capturing media from the specified device and closes the MediaStream object.
2828
/// </summary>
29+
/// <param name="videoSelector"></param>
2930
/// <returns></returns>
30-
Task Close();
31+
Task Close(string? videoSelector);
3132

3233
/// <summary>
3334
/// The capture() method of the MediaDevices interface captures a still image from the specified video stream and saves it to the specified location.

src/BootstrapBlazor/Services/MediaDevices/IMediaVideo.cs renamed to src/BootstrapBlazor/Services/MediaDevices/IVideoDevice.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace BootstrapBlazor.Components;
88
/// <summary>
99
/// Video Media Device Interface
1010
/// </summary>
11-
public interface IMediaVideo
11+
public interface IVideoDevice
1212
{
1313
/// <summary>
1414
/// Gets the list of video devices.
@@ -26,8 +26,9 @@ public interface IMediaVideo
2626
/// <summary>
2727
/// Close the video device with the specified selector.
2828
/// </summary>
29+
/// <param name="videoSelector"></param>
2930
/// <returns></returns>
30-
Task Close();
31+
Task Close(string? videoSelector);
3132

3233
/// <summary>
3334
/// Capture a still image from the video stream.

src/BootstrapBlazor/Services/MediaDevices/MediaTrackConstraints.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ public class MediaTrackConstraints
2323
/// <summary>
2424
///
2525
/// </summary>
26-
public int Width { get; set; }
26+
public int? Width { get; set; }
2727

2828
/// <summary>
2929
///
3030
/// </summary>
31-
public int Height { get; set; }
31+
public int? Height { get; set; }
3232

3333
/// <summary>
3434
///

0 commit comments

Comments
 (0)