
Camera
This component takes pictures by calling the camera
Pay special attention to:
- The site wants to enable
https
, which is required by browser vendors - The site wants to enable
https
, which is required by browser vendors - The site wants to enable
https
, which is required by browser vendors
Take pictures through the camera
Demo
Set the AutoStart
property to control whether the camera is directly turned on when the component is running
Demo
Attributes
@page "/cameras"
@inject IStringLocalizer<Cameras> Localizer
<h3>Camera</h3>
<h4>This component takes pictures by calling the camera</h4>
<p><b>Pay special attention to:</b></p>
<ul class="ul-demo">
<li>The site wants to enable <code>https</code>, which is required by browser vendors</li>
<li>The site wants to enable <code>https</code>, which is required by browser vendors</li>
<li>The site wants to enable <code>https</code>, which is required by browser vendors</li>
</ul>
<DemoBlock Title="Basic usage" Introduction="Take pictures through the camera" Name="Normal" Demo="typeof(Demos.Camera.CameraNormal)">
<p>Steps:</p>
<ul class="ul-demo mb-3">
<li>Click start to open the camera</li>
<li>Click the photo button</li>
<li>Click the close button to close the camera</li>
</ul>
</DemoBlock>
<DemoBlock Title="Show preview" Introduction="Set the <code>ShowPreview</code> property to control whether to display the photo preview" Name="ShowPreview" Demo="typeof(Demos.Camera.CameraShowPreview)" />
<DemoBlock Title="Start automatically" Introduction="Set the <code>AutoStart</code> property to control whether the camera is directly turned on when the component is running" Name="AutoStart" Demo="typeof(Demos.Camera.CameraAutoStart)" />
<AttributeTable Items="@GetAttributes()" />
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/
namespace BootstrapBlazor.Shared.Samples;
/// <summary>
///
/// </summary>
public sealed partial class Cameras
{
/// <summary>
/// 获得属性方法
/// </summary>
/// <returns></returns>
private IEnumerable<AttributeItem> GetAttributes() => new AttributeItem[]
{
// TODO: 移动到数据库中
new AttributeItem() {
Name = nameof(Camera.VideoWidth),
Description = Localizer["VideoWidth"],
Type = "int",
ValueList = " — ",
DefaultValue = "320"
},
new AttributeItem() {
Name = nameof(Camera.VideoHeight),
Description = Localizer["VideoHeight"],
Type = "int",
ValueList = " — ",
DefaultValue = "240"
},
new AttributeItem() {
Name = "ShowPreview",
Description = Localizer["ShowPreview"],
Type = "bool",
ValueList = "true|false",
DefaultValue = "false"
},
new AttributeItem() {
Name = "AutoStart",
Description = Localizer["AutoStart"],
Type = "bool",
ValueList = "true|false",
DefaultValue = "false"
},
new AttributeItem() {
Name = "DeviceLabel",
Description = Localizer["DeviceLabel"],
Type = "string",
ValueList = " — ",
DefaultValue = " — "
},
new AttributeItem() {
Name = "FrontText",
Description = Localizer["FrontText"],
Type = "string",
ValueList = " — ",
DefaultValue = " — "
},
new AttributeItem() {
Name = "BackText",
Description = Localizer["FrontText"],
Type = "string",
ValueList = " — ",
DefaultValue = " — "
},
new AttributeItem() {
Name = "PlayText",
Description = "",
Type = "string",
ValueList = " — ",
DefaultValue = " — "
},
new AttributeItem() {
Name = "StopText",
Description = Localizer["FrontText"],
Type = "string",
ValueList = " — ",
DefaultValue = " — "
},
new AttributeItem() {
Name = "PhotoText",
Description = Localizer["FrontText"],
Type = "string",
ValueList = " — ",
DefaultValue = " — "
},
new AttributeItem() {
Name = "InitDevicesString",
Description = Localizer["InitDevicesString"],
Type = "string",
ValueList = " — ",
DefaultValue = Localizer["InitDevicesStringDefaultValue"]
},
new AttributeItem()
{
Name = "NotFoundDevicesString",
Description = Localizer["NotFoundDevicesString"],
Type = "string",
ValueList = " — ",
DefaultValue = Localizer["NotFoundDevicesStringDefaultValue"]
},
new AttributeItem() {
Name = "OnInit",
Description = Localizer["OnInit"],
Type = "Func<IEnumerable<DeviceItem>, Task>",
ValueList = " — ",
DefaultValue = " — "
},
new AttributeItem() {
Name = "OnStart",
Description = Localizer["OnStart"],
Type = "Func<Task>",
ValueList = " — ",
DefaultValue = " — "
},
new AttributeItem() {
Name = "OnClose",
Description = Localizer["OnClose"],
Type = "Func<Task>",
ValueList = " — ",
DefaultValue = " — "
},
new AttributeItem() {
Name = "OnCapture",
Description = Localizer["OnCapture"],
Type = "Func<string, Task>",
ValueList = " — ",
DefaultValue = " — "
}
};
}