Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
mobile_scanner
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Navaron Bracke
2023-11-29 19:33:17 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
07daf49001a087cd413b05e74e80e053c0fd13df
07daf490
1 parent
3fe3f573
add missing DispatchQueue.main switch for scale & torch on iOS
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
12 deletions
ios/Classes/MobileScanner.swift
ios/Classes/MobileScanner.swift
View file @
07daf49
...
...
@@ -215,26 +215,35 @@ public class MobileScanner: NSObject, AVCaptureVideoDataOutputSampleBufferDelega
backgroundQueue
.
async
{
self
.
captureSession
.
startRunning
()
// Turn on the flashlight if requested,
// but after the capture session started.
// After the capture session started, turn on the torch (if requested)
// and reset the zoom scale back to the default.
// Ensure that these adjustments are done on the main DispatchQueue,
// as they interact with the hardware camera.
if
(
torch
)
{
DispatchQueue
.
main
.
async
{
do
{
try
self
.
toggleTorch
(
.
on
)
}
catch
{
// If the torch does not turn on,
// continue with the capture session anyway.
}
}
}
DispatchQueue
.
main
.
async
{
do
{
try
self
.
toggleTorch
(
.
on
)
try
self
.
resetScale
(
)
}
catch
{
// If the
torch does not turn on
,
// If the
zoom scale could not be reset
,
// continue with the capture session anyway.
}
}
do
{
try
self
.
resetScale
()
}
catch
{
// If the zoom scale could not be reset,
// continue with the capture session anyway.
}
if
let
device
=
self
.
device
{
// When querying the dimensions of the camera,
// stay on the background thread,
// as this does not change the configuration of the hardware camera.
let
dimensions
=
CMVideoFormatDescriptionGetDimensions
(
device
.
activeFormat
.
formatDescription
)
let
hasTorch
=
device
.
hasTorch
...
...
Please
register
or
login
to post a comment