This repository was archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[camera] Request access permission for audio #5766
Merged
fluttergithubbot
merged 5 commits into
flutter:main
from
hellohuanlin:camera_permission_for_audio
May 18, 2022
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e8e213e
[camera]request access permission for audio
hellohuanlin 141025c
updates readme and example to add audio exception codes
hellohuanlin 67f9435
split audio and video request functions
hellohuanlin cb3ecc6
add back WithCompletionHandler
hellohuanlin a169b34
rqeuest audio permission on create call instead of prepareForVideoRec…
hellohuanlin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
[camera]request access permission for audio
- Loading branch information
commit e8e213ed7b3b08c662152ace3630738aa75aca20
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -132,12 +132,12 @@ - (void)handleMethodCallAsync:(FlutterMethodCall *)call | |
| [result sendNotImplemented]; | ||
| } | ||
| } else if ([@"create" isEqualToString:call.method]) { | ||
| FLTRequestCameraPermissionWithCompletionHandler(^(FlutterError *error) { | ||
| FLTRequestCameraPermission(/*forAudio*/ false, ^(FlutterError *error) { | ||
|
||
| // Create FLTCam only if granted camera access. | ||
| if (error) { | ||
| [result sendFlutterError:error]; | ||
| } else { | ||
| [self createCameraOnSessionQueueWithCreateMethodCall:call result:result]; | ||
| [self createCameraOnCaptureSessionQueueWithCreateMethodCall:call result:result]; | ||
| } | ||
| }); | ||
| } else if ([@"startImageStream" isEqualToString:call.method]) { | ||
|
|
@@ -194,8 +194,17 @@ - (void)handleMethodCallAsync:(FlutterMethodCall *)call | |
| [_camera close]; | ||
| [result sendSuccess]; | ||
| } else if ([@"prepareForVideoRecording" isEqualToString:call.method]) { | ||
| [_camera setUpCaptureSessionForAudio]; | ||
| [result sendSuccess]; | ||
| FLTRequestCameraPermission(/*forAudio*/ true, ^(FlutterError *error) { | ||
| // Setup audio capture session only if granted audio access | ||
| if (error) { | ||
| [result sendFlutterError:error]; | ||
| } else { | ||
| dispatch_async(self.captureSessionQueue, ^{ | ||
| [self.camera setUpCaptureSessionForAudio]; | ||
| [result sendSuccess]; | ||
| }); | ||
| } | ||
| }); | ||
| } else if ([@"startVideoRecording" isEqualToString:call.method]) { | ||
| [_camera startVideoRecordingWithResult:result]; | ||
| } else if ([@"stopVideoRecording" isEqualToString:call.method]) { | ||
|
|
@@ -258,8 +267,8 @@ - (void)handleMethodCallAsync:(FlutterMethodCall *)call | |
| } | ||
| } | ||
|
|
||
| - (void)createCameraOnSessionQueueWithCreateMethodCall:(FlutterMethodCall *)createMethodCall | ||
| result:(FLTThreadSafeFlutterResult *)result { | ||
| - (void)createCameraOnCaptureSessionQueueWithCreateMethodCall:(FlutterMethodCall *)createMethodCall | ||
| result:(FLTThreadSafeFlutterResult *)result { | ||
| dispatch_async(self.captureSessionQueue, ^{ | ||
| NSString *cameraName = createMethodCall.arguments[@"cameraName"]; | ||
| NSString *resolutionPreset = createMethodCall.arguments[@"resolutionPreset"]; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know
authorizationStatusForMediaType:mediaTypewas already used before, but should this be+requestAccessForMediaType:completionHandler:instead to actually request it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh we should always check the status first, and only request the permission if it's in
.notDeterminedstatus.