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
2024-02-28 09:12:36 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d988553d920ebeded70b57fdd43cf62beae18b90
d988553d
1 parent
386d0a8f
let torch state notify that it is unsupported
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
42 deletions
lib/src/web/barcode_reader.dart
lib/src/web/mobile_scanner_web.dart
lib/src/web/zxing/zxing_barcode_reader.dart
lib/src/web/barcode_reader.dart
View file @
d988553
...
...
@@ -43,7 +43,9 @@ abstract class BarcodeReader {
/// Check whether the active camera has a flashlight.
Future
<
bool
>
hasTorch
()
{
throw
UnimplementedError
(
'hasTorch() has not been implemented.'
);
// The torch of a media stream is not available for video tracks.
// See https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints#instance_properties_of_video_tracks
return
Future
<
bool
>.
value
(
false
);
}
/// Load the barcode reader library.
...
...
@@ -108,7 +110,10 @@ abstract class BarcodeReader {
/// Set the torch state for the active camera to the given [value].
Future
<
void
>
setTorchState
(
TorchState
value
)
{
throw
UnimplementedError
(
'setTorchState() has not been implemented.'
);
throw
UnsupportedError
(
'Setting the torch state is not supported for video tracks on the web.
\n
'
'See https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints#instance_properties_of_video_tracks'
,
);
}
/// Start the barcode reader and initialize the [videoStream].
...
...
lib/src/web/mobile_scanner_web.dart
View file @
d988553
...
...
@@ -77,7 +77,7 @@ class MobileScannerWeb extends MobileScannerPlatform {
@override
Stream
<
TorchState
>
get
torchStateStream
=>
_settingsController
.
stream
.
map
((
_
)
=>
TorchState
.
off
);
_settingsController
.
stream
.
map
((
_
)
=>
TorchState
.
unavailable
);
@override
Stream
<
double
>
get
zoomScaleStateStream
=>
...
...
lib/src/web/zxing/zxing_barcode_reader.dart
View file @
d988553
...
...
@@ -3,7 +3,6 @@ import 'dart:js_interop';
import
'dart:ui'
;
import
'package:mobile_scanner/src/enums/barcode_format.dart'
;
import
'package:mobile_scanner/src/enums/torch_state.dart'
;
import
'package:mobile_scanner/src/objects/barcode_capture.dart'
;
import
'package:mobile_scanner/src/objects/start_options.dart'
;
import
'package:mobile_scanner/src/web/barcode_reader.dart'
;
...
...
@@ -165,17 +164,6 @@ final class ZXingBarcodeReader extends BarcodeReader {
}
@override
Future
<
bool
>
hasTorch
()
{
final
web
.
MediaStream
?
mediaStream
=
_reader
?.
stream
;
if
(
mediaStream
==
null
)
{
return
Future
<
bool
>.
value
(
false
);
}
return
_mediaTrackConstraintsDelegate
.
hasFlashlight
(
mediaStream
);
}
@override
void
setMediaTrackSettingsListener
(
void
Function
(
web
.
MediaTrackSettings
)
listener
,
)
{
...
...
@@ -183,33 +171,6 @@ final class ZXingBarcodeReader extends BarcodeReader {
}
@override
Future
<
void
>
setTorchState
(
TorchState
value
)
async
{
switch
(
value
)
{
case
TorchState
.
unavailable
:
return
Future
<
void
>.
value
();
case
TorchState
.
off
:
case
TorchState
.
on
:
final
web
.
MediaStream
?
mediaStream
=
_reader
?.
stream
;
if
(
mediaStream
==
null
)
{
return
Future
<
void
>.
value
();
}
await
_mediaTrackConstraintsDelegate
.
setFlashlightState
(
mediaStream
,
value
,
);
final
web
.
MediaTrackSettings
?
settings
=
_mediaTrackConstraintsDelegate
.
getSettings
(
mediaStream
);
if
(
settings
!=
null
)
{
_onMediaTrackSettingsChanged
?.
call
(
settings
);
}
}
}
@override
Future
<
void
>
start
(
StartOptions
options
,
{
required
web
.
HTMLVideoElement
videoElement
,
...
...
Please
register
or
login
to post a comment