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
fumin65
2024-03-25 22:08:15 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
09df0efb1432508ad87277d698c8e15baa825461
09df0efb
1 parent
b151eba2
add pause function to web part
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
0 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 @
09df0ef
...
...
@@ -129,6 +129,11 @@ abstract class BarcodeReader {
throw
UnimplementedError
(
'start() has not been implemented.'
);
}
/// Pause the barcode reader.
Future
<
void
>
pause
()
{
throw
UnimplementedError
(
'pause() has not been implemented.'
);
}
/// Stop the barcode reader and dispose of the video stream.
Future
<
void
>
stop
()
{
throw
UnimplementedError
(
'stop() has not been implemented.'
);
...
...
lib/src/web/mobile_scanner_web.dart
View file @
09df0ef
import
'dart:async'
;
import
'dart:developer'
;
import
'dart:html'
;
import
'dart:js_interop'
;
import
'dart:ui_web'
as
ui_web
;
...
...
@@ -235,6 +237,11 @@ class MobileScannerWeb extends MobileScannerPlatform {
throw
PermissionRequestPendingException
();
}
// If the previous state is a pause, reset scanner.
if
(
_barcodesSubscription
!=
null
&&
_barcodesSubscription
!.
isPaused
)
{
await
stop
();
}
await
_barcodeReader
.
maybeLoadLibrary
(
alternateScriptUrl:
_alternateScriptUrl
,
);
...
...
@@ -336,6 +343,13 @@ class MobileScannerWeb extends MobileScannerPlatform {
}
}
@override
Future
<
void
>
pause
()
async
{
_barcodesSubscription
?.
pause
();
await
_barcodeReader
.
pause
();
}
@override
Future
<
void
>
stop
()
async
{
if
(
_barcodesController
.
isClosed
)
{
...
...
lib/src/web/zxing/zxing_barcode_reader.dart
View file @
09df0ef
...
...
@@ -192,6 +192,11 @@ final class ZXingBarcodeReader extends BarcodeReader {
}
@override
Future
<
void
>
pause
()
async
{
_reader
?.
videoElement
?.
pause
();
}
@override
Future
<
void
>
stop
()
async
{
_onMediaTrackSettingsChanged
=
null
;
_reader
?.
stopContinuousDecode
.
callAsFunction
(
_reader
as
JSAny
?);
...
...
Please
register
or
login
to post a comment