Skip to content

Commit f7af7c2

Browse files
[camera_platform_interface] implement setDescriptionWhileRecording with android camerax (#9998)
implement platform changes for setDescriptionWhileRecording feature with android camerax Fixes [#148013](flutter/flutter#148013) ## Pre-Review Checklist **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
1 parent d2bbb92 commit f7af7c2

File tree

4 files changed

+29
-5
lines changed

4 files changed

+29
-5
lines changed

packages/camera/camera_platform_interface/CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
## NEXT
1+
## 2.11.0
22

3+
* Adds a flag to configure a recording to be persistent across camera changes. See
4+
`VideoCaptureOptions.enablePersistentRecording`.
35
* Updates minimum supported SDK version to Flutter 3.29/Dart 3.7.
46

57
## 2.10.0

packages/camera/camera_platform_interface/lib/src/platform_interface/camera_platform.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,10 @@ abstract class CameraPlatform extends PlatformInterface {
292292
}
293293

294294
/// Sets the active camera while recording.
295+
///
296+
/// On Android, you must start the recording with [startVideoCapturing]
297+
/// with `enablePersistentRecording` set to `true`
298+
/// to avoid cancelling any active recording.
295299
Future<void> setDescriptionWhileRecording(CameraDescription description) {
296300
throw UnimplementedError(
297301
'setDescriptionWhileRecording() is not implemented.',

packages/camera/camera_platform_interface/lib/src/types/video_capture_options.dart

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class VideoCaptureOptions {
1818
this.maxDuration,
1919
this.streamCallback,
2020
this.streamOptions,
21+
this.enablePersistentRecording = true,
2122
}) : assert(
2223
streamOptions == null || streamCallback != null,
2324
'Must specify streamCallback if providing streamOptions.',
@@ -43,6 +44,17 @@ class VideoCaptureOptions {
4344
/// Should only be set if a streamCallback is also present.
4445
final CameraImageStreamOptions? streamOptions;
4546

47+
/// Configures the recording to be a persistent recording.
48+
///
49+
/// A persistent recording can only be stopped by explicitly calling [CameraPlatform.stopVideoRecording]
50+
/// and will ignore events that would normally cause recording to stop, such as lifecycle events.
51+
///
52+
/// On Android, you must set this parameter to `true`
53+
/// to avoid cancelling any active recording when calling [CameraPlatform.setDescriptionWhileRecording].
54+
///
55+
/// Defaults to `true`.
56+
final bool enablePersistentRecording;
57+
4658
@override
4759
bool operator ==(Object other) =>
4860
identical(this, other) ||
@@ -51,9 +63,15 @@ class VideoCaptureOptions {
5163
cameraId == other.cameraId &&
5264
maxDuration == other.maxDuration &&
5365
streamCallback == other.streamCallback &&
54-
streamOptions == other.streamOptions;
66+
streamOptions == other.streamOptions &&
67+
enablePersistentRecording == other.enablePersistentRecording;
5568

5669
@override
57-
int get hashCode =>
58-
Object.hash(cameraId, maxDuration, streamCallback, streamOptions);
70+
int get hashCode => Object.hash(
71+
cameraId,
72+
maxDuration,
73+
streamCallback,
74+
streamOptions,
75+
enablePersistentRecording,
76+
);
5977
}

packages/camera/camera_platform_interface/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ repository: https://github.com/flutter/packages/tree/main/packages/camera/camera
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
55
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
66
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
7-
version: 2.10.0
7+
version: 2.11.0
88

99
environment:
1010
sdk: ^3.7.0

0 commit comments

Comments
 (0)