Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[camera] flip/change camera while recording - platform interface #7011

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/camera/camera_platform_interface/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## NEXT
## 2.4.0

* Allows camera to be switched while video recording.
* Updates minimum Flutter version to 3.0.

## 2.3.4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,17 @@ class MethodChannelCamera extends CameraPlatform {
);
}

@override
Future<void> setDescriptionWhileRecording(
CameraDescription description) async {
await _channel.invokeMethod<double>(
'setDescriptionWhileRecording',
<String, dynamic>{
'cameraName': description.name,
},
);
}

@override
Widget buildPreview(int cameraId) {
return Texture(textureId: cameraId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,12 @@ abstract class CameraPlatform extends PlatformInterface {
throw UnimplementedError('pausePreview() is not implemented.');
}

/// Sets the active camera while recording.
Future<void> setDescriptionWhileRecording(CameraDescription description) {
throw UnimplementedError(
'setDescriptionWhileRecording() is not implemented.');
}

/// Returns a widget showing a live camera preview.
Widget buildPreview(int cameraId) {
throw UnimplementedError('buildView() has not been implemented.');
Expand Down
2 changes: 1 addition & 1 deletion packages/camera/camera_platform_interface/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ repository: https://github.com/flutter/plugins/tree/main/packages/camera/camera_
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
version: 2.3.4
version: 2.4.0

environment:
sdk: '>=2.12.0 <3.0.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,29 @@ void main() {
]);
});

test('Should set description while recording', () async {
// Arrange
final MethodChannelMock channel = MethodChannelMock(
channelName: 'plugins.flutter.io/camera',
methods: <String, dynamic>{'setDescriptionWhileRecording': null},
);

// Act
const CameraDescription cameraDescription = CameraDescription(
name: 'Test',
lensDirection: CameraLensDirection.back,
sensorOrientation: 0);
await camera.setDescriptionWhileRecording(cameraDescription);

// Assert
expect(channel.log, <Matcher>[
isMethodCall('setDescriptionWhileRecording',
arguments: <String, Object?>{
'cameraName': cameraDescription.name
}),
]);
});

test('Should pass maxVideoDuration when starting recording a video',
() async {
// Arrange
Expand Down