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

Commit

Permalink
[camera] flip/change camera while recording - platform interface (#7011)
Browse files Browse the repository at this point in the history
* platform interface changes pr

* changes version to 2.4

* fixes versioning

---------

Co-authored-by: BradenBagby <[email protected]>
  • Loading branch information
BradenBagby and BradenBagbyWavv authored Feb 6, 2023
1 parent 8838645 commit 7a63dbc
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 2 deletions.
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

0 comments on commit 7a63dbc

Please sign in to comment.