When valueField/textField are not explicitly set in opts, the auto-select logic (line 1140) and nullable empty-option creation (lines 1144-1145) used data[0][undefined] which returned undefined, causing: - Single-option selects to show blank (auto-select failed) - nullable empty options to have undefined keys Now extracts vf/tf local variables with ||'value'/||'text' fallback at the top of build_options(), used consistently throughout.
1.4 KiB
1.4 KiB
Camera
Widget Functionality: Used to access the device's camera for taking photos or recording videos. Supports features such as switching cameras, starting/stopping video recording, and capturing photos.
Type: Standard widget (an extension based on Popup)
Parent Widget: bricks.Popup
Initialization Parameters
| Parameter | Type | Description |
|---|---|---|
fps |
Number | Frame rate for video capture; default is 60 FPS |
type |
String | Widget mode; allowed values are 'picture' (photo mode) or 'recorder' (video recording mode) |
auto_dismiss |
Boolean | Whether the popup should automatically close; default is false (explicitly set in code) |
Note
:
opts.auto_dismiss = false;is forcibly set within the constructor.
Main Events
| Event | Trigger Condition | Data Carried |
|---|---|---|
shot |
Triggered when the user clicks the capture button | The captured image data URL (JPEG image in base64 format) |
recorded |
Triggered when video recording ends | The recorded video file object (File type, WebM format) |
Explanation:
- When
type='picture', clicking the capture button triggers theshotevent and returns the captured image data.- When
type='recorder', clicking the record button starts or stops recording. After stopping, therecordedevent is triggered and returns the recorded video file.