Skip to content

Commit 6791f67

Browse files
ABausGbselwe
authored andcommitted
[camera_web] Add video recording functionality (flutter#4210)
* feat: Add Support for Video Recording in Camera Web * docs: add video recording documentation Co-authored-by: Bartosz Selwesiuk <[email protected]>
1 parent 738c94c commit 6791f67

File tree

11 files changed

+1622
-81
lines changed

11 files changed

+1622
-81
lines changed

packages/camera/camera/lib/src/camera_controller.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ class CameraController extends ValueNotifier<CameraValue> {
335335
/// Preparing audio can cause a minor delay in the CameraPreview view on iOS.
336336
/// If video recording is intended, calling this early eliminates this delay
337337
/// that would otherwise be experienced when video recording is started.
338-
/// This operation is a no-op on Android.
338+
/// This operation is a no-op on Android and Web.
339339
///
340340
/// Throws a [CameraException] if the prepare fails.
341341
Future<void> prepareForVideoRecording() async {

packages/camera/camera_web/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
## NEXT
1+
## 0.2.1
22

3+
* Add video recording functionality.
34
* Fix cameraNotReadable error that prevented access to the camera on some Android devices.
45

56
## 0.2.0

packages/camera/camera_web/README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,24 @@ if (kIsWeb) {
8383
}
8484
```
8585

86+
### Video recording
87+
88+
The video recording implementation is backed by [MediaRecorder Web API](https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder) with the following [browser support](https://caniuse.com/mdn-api_mediarecorder):
89+
90+
![Data on support for the MediaRecorder feature across the major browsers from caniuse.com](https://caniuse.bitsofco.de/image/mediarecorder.png).
91+
92+
A video is recorded in one of the following video MIME types:
93+
- video/webm (e.g. on Chrome or Firefox)
94+
- video/mp4 (e.g. on Safari)
95+
96+
Pausing, resuming or stopping the video recording throws a `PlatformException` with the `videoRecordingNotStarted` error code if the video recording was not started.
97+
98+
For the browsers that do not support the video recording:
99+
- `CameraPlatform.startVideoRecording` throws a `PlatformException` with the `notSupported` error code.
100+
86101
## Missing implementation
87102

88103
The web implementation of [`camera`][camera] is missing the following features:
89-
90-
- Video recording ([in progress](https://github.com/flutter/plugins/pull/4210))
91104
- Exposure mode, point and offset
92105
- Focus mode and point
93106
- Sensor orientation

packages/camera/camera_web/example/integration_test/camera_error_code_test.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,13 @@ void main() {
113113
);
114114
});
115115

116+
testWidgets('videoRecordingNotStarted', (tester) async {
117+
expect(
118+
CameraErrorCode.videoRecordingNotStarted.toString(),
119+
equals('videoRecordingNotStarted'),
120+
);
121+
});
122+
116123
testWidgets('unknown', (tester) async {
117124
expect(
118125
CameraErrorCode.unknown.toString(),

0 commit comments

Comments
 (0)