Skip to content

Commit

Permalink
[camera_web] Add video recording functionality (flutter#4210)
Browse files Browse the repository at this point in the history
* feat: Add Support for Video Recording in Camera Web
* docs: add video recording documentation

Co-authored-by: Bartosz Selwesiuk <[email protected]>
  • Loading branch information
2 people authored and amantoux committed Sep 27, 2021
1 parent bc53e1c commit 5517a96
Show file tree
Hide file tree
Showing 11 changed files with 1,622 additions and 81 deletions.
2 changes: 1 addition & 1 deletion packages/camera/camera/lib/src/camera_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ class CameraController extends ValueNotifier<CameraValue> {
/// Preparing audio can cause a minor delay in the CameraPreview view on iOS.
/// If video recording is intended, calling this early eliminates this delay
/// that would otherwise be experienced when video recording is started.
/// This operation is a no-op on Android.
/// This operation is a no-op on Android and Web.
///
/// Throws a [CameraException] if the prepare fails.
Future<void> prepareForVideoRecording() async {
Expand Down
3 changes: 2 additions & 1 deletion packages/camera/camera_web/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## NEXT
## 0.2.1

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

## 0.2.0
Expand Down
17 changes: 15 additions & 2 deletions packages/camera/camera_web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,24 @@ if (kIsWeb) {
}
```

### Video recording

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):

![Data on support for the MediaRecorder feature across the major browsers from caniuse.com](https://caniuse.bitsofco.de/image/mediarecorder.png).

A video is recorded in one of the following video MIME types:
- video/webm (e.g. on Chrome or Firefox)
- video/mp4 (e.g. on Safari)

Pausing, resuming or stopping the video recording throws a `PlatformException` with the `videoRecordingNotStarted` error code if the video recording was not started.

For the browsers that do not support the video recording:
- `CameraPlatform.startVideoRecording` throws a `PlatformException` with the `notSupported` error code.

## Missing implementation

The web implementation of [`camera`][camera] is missing the following features:

- Video recording ([in progress](https://github.com/flutter/plugins/pull/4210))
- Exposure mode, point and offset
- Focus mode and point
- Sensor orientation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ void main() {
);
});

testWidgets('videoRecordingNotStarted', (tester) async {
expect(
CameraErrorCode.videoRecordingNotStarted.toString(),
equals('videoRecordingNotStarted'),
);
});

testWidgets('unknown', (tester) async {
expect(
CameraErrorCode.unknown.toString(),
Expand Down
Loading

0 comments on commit 5517a96

Please sign in to comment.