mirror of
https://github.com/flutter/packages.git
synced 2025-06-30 14:47:22 +08:00
[camera] Removed the microphone permission request from availableCameras on Web (#4263)
I've removed the microphone permission request from availableCameras on Web. Adding an additional parameter would break either web or android/ios, so in my opinion it is better to change the web behavior. Changes were made based on this issue: https://github.com/flutter/flutter/issues/112277
This commit is contained in:

committed by
GitHub

parent
60e9a542f9
commit
9074ea9e38
@ -1,3 +1,7 @@
|
||||
## 0.3.2
|
||||
|
||||
* Changes `availableCameras` to not ask for the microphone permission.
|
||||
|
||||
## 0.3.1+4
|
||||
|
||||
* Removes obsolete null checks on non-nullable values.
|
||||
|
@ -98,24 +98,18 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('requests video and audio permissions',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('requests video permissions', (WidgetTester tester) async {
|
||||
final List<CameraDescription> _ =
|
||||
await CameraPlatform.instance.availableCameras();
|
||||
|
||||
verify(
|
||||
() => cameraService.getMediaStreamForOptions(
|
||||
const CameraOptions(
|
||||
audio: AudioConstraints(enabled: true),
|
||||
),
|
||||
),
|
||||
() => cameraService.getMediaStreamForOptions(const CameraOptions()),
|
||||
).called(1);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'releases the camera stream '
|
||||
'used to request video and audio permissions',
|
||||
(WidgetTester tester) async {
|
||||
'used to request video permissions', (WidgetTester tester) async {
|
||||
final MockMediaStreamTrack videoTrack = MockMediaStreamTrack();
|
||||
|
||||
bool videoTrackStopped = false;
|
||||
@ -124,11 +118,7 @@ void main() {
|
||||
});
|
||||
|
||||
when(
|
||||
() => cameraService.getMediaStreamForOptions(
|
||||
const CameraOptions(
|
||||
audio: AudioConstraints(enabled: true),
|
||||
),
|
||||
),
|
||||
() => cameraService.getMediaStreamForOptions(const CameraOptions()),
|
||||
).thenAnswer(
|
||||
(_) => Future<MediaStream>.value(
|
||||
FakeMediaStream(<MediaStreamTrack>[videoTrack]),
|
||||
|
@ -96,15 +96,11 @@ class CameraPlugin extends CameraPlatform {
|
||||
);
|
||||
}
|
||||
|
||||
// Request video and audio permissions.
|
||||
// Request video permissions only.
|
||||
final html.MediaStream cameraStream =
|
||||
await _cameraService.getMediaStreamForOptions(
|
||||
const CameraOptions(
|
||||
audio: AudioConstraints(enabled: true),
|
||||
),
|
||||
);
|
||||
await _cameraService.getMediaStreamForOptions(const CameraOptions());
|
||||
|
||||
// Release the camera stream used to request video and audio permissions.
|
||||
// Release the camera stream used to request video permissions.
|
||||
cameraStream
|
||||
.getVideoTracks()
|
||||
.forEach((html.MediaStreamTrack videoTrack) => videoTrack.stop());
|
||||
|
@ -2,7 +2,7 @@ name: camera_web
|
||||
description: A Flutter plugin for getting information about and controlling the camera on Web.
|
||||
repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_web
|
||||
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
|
||||
version: 0.3.1+4
|
||||
version: 0.3.2
|
||||
|
||||
environment:
|
||||
sdk: ">=2.18.0 <4.0.0"
|
||||
|
Reference in New Issue
Block a user