Showing
4 changed files
with
24 additions
and
24 deletions
| @@ -95,8 +95,8 @@ abstract class BarcodeReader { | @@ -95,8 +95,8 @@ abstract class BarcodeReader { | ||
| 95 | await completer.future; | 95 | await completer.future; |
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | - /// Set a listener for the media stream constraints. | ||
| 99 | - void setMediaTrackConstraintsListener(void Function(MediaTrackConstraints) listener) { | 98 | + /// Set a listener for the media stream settings. |
| 99 | + void setMediaTrackSettingsListener(void Function(MediaTrackSettings) listener) { | ||
| 100 | throw UnimplementedError( | 100 | throw UnimplementedError( |
| 101 | 'setMediaTrackConstraintsListener() has not been implemented.', | 101 | 'setMediaTrackConstraintsListener() has not been implemented.', |
| 102 | ); | 102 | ); |
| @@ -8,8 +8,8 @@ final class MediaTrackConstraintsDelegate { | @@ -8,8 +8,8 @@ final class MediaTrackConstraintsDelegate { | ||
| 8 | /// Constructs a [MediaTrackConstraintsDelegate] instance. | 8 | /// Constructs a [MediaTrackConstraintsDelegate] instance. |
| 9 | const MediaTrackConstraintsDelegate(); | 9 | const MediaTrackConstraintsDelegate(); |
| 10 | 10 | ||
| 11 | - /// Get the constraints for the given [mediaStream]. | ||
| 12 | - MediaTrackConstraints? getConstraints(MediaStream? mediaStream) { | 11 | + /// Get the settings for the given [mediaStream]. |
| 12 | + MediaTrackSettings? getSettings(MediaStream? mediaStream) { | ||
| 13 | final List<JSAny?> tracks = mediaStream?.getVideoTracks().toDart ?? const []; | 13 | final List<JSAny?> tracks = mediaStream?.getVideoTracks().toDart ?? const []; |
| 14 | 14 | ||
| 15 | if (tracks.isEmpty) { | 15 | if (tracks.isEmpty) { |
| @@ -18,7 +18,7 @@ final class MediaTrackConstraintsDelegate { | @@ -18,7 +18,7 @@ final class MediaTrackConstraintsDelegate { | ||
| 18 | 18 | ||
| 19 | final MediaStreamTrack? track = tracks.first as MediaStreamTrack?; | 19 | final MediaStreamTrack? track = tracks.first as MediaStreamTrack?; |
| 20 | 20 | ||
| 21 | - return track?.getConstraints(); | 21 | + return track?.getSettings(); |
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | /// Returns a list of supported flashlight modes for the given [mediaStream]. | 24 | /// Returns a list of supported flashlight modes for the given [mediaStream]. |
| @@ -33,8 +33,8 @@ class MobileScannerWeb extends MobileScannerPlatform { | @@ -33,8 +33,8 @@ class MobileScannerWeb extends MobileScannerPlatform { | ||
| 33 | /// This container element is used by the barcode reader. | 33 | /// This container element is used by the barcode reader. |
| 34 | HTMLDivElement? _divElement; | 34 | HTMLDivElement? _divElement; |
| 35 | 35 | ||
| 36 | - /// The stream controller for the media track constraints stream. | ||
| 37 | - final StreamController<MediaTrackConstraints> _constraintsController = StreamController.broadcast(); | 36 | + /// The stream controller for the media track settings stream. |
| 37 | + final StreamController<MediaTrackSettings> _settingsController = StreamController.broadcast(); | ||
| 38 | 38 | ||
| 39 | /// The view type for the platform view factory. | 39 | /// The view type for the platform view factory. |
| 40 | final String _viewType = 'MobileScannerWeb'; | 40 | final String _viewType = 'MobileScannerWeb'; |
| @@ -46,12 +46,12 @@ class MobileScannerWeb extends MobileScannerPlatform { | @@ -46,12 +46,12 @@ class MobileScannerWeb extends MobileScannerPlatform { | ||
| 46 | @override | 46 | @override |
| 47 | Stream<BarcodeCapture?> get barcodesStream => _barcodesController.stream; | 47 | Stream<BarcodeCapture?> get barcodesStream => _barcodesController.stream; |
| 48 | 48 | ||
| 49 | - void _handleMediaTrackConstraintsChange(MediaTrackConstraints constraints) { | ||
| 50 | - if (_constraintsController.isClosed) { | 49 | + void _handleMediaTrackSettingsChange(MediaTrackSettings settings) { |
| 50 | + if (_settingsController.isClosed) { | ||
| 51 | return; | 51 | return; |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | - _constraintsController.add(constraints); | 54 | + _settingsController.add(settings); |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | @override | 57 | @override |
| @@ -97,8 +97,8 @@ class MobileScannerWeb extends MobileScannerPlatform { | @@ -97,8 +97,8 @@ class MobileScannerWeb extends MobileScannerPlatform { | ||
| 97 | // Clear the existing barcodes. | 97 | // Clear the existing barcodes. |
| 98 | _barcodesController.add(const BarcodeCapture()); | 98 | _barcodesController.add(const BarcodeCapture()); |
| 99 | 99 | ||
| 100 | - // Listen for changes to the media track constraints. | ||
| 101 | - _barcodeReader.setMediaTrackConstraintsListener(_handleMediaTrackConstraintsChange); | 100 | + // Listen for changes to the media track settings. |
| 101 | + _barcodeReader.setMediaTrackSettingsListener(_handleMediaTrackSettingsChange); | ||
| 102 | 102 | ||
| 103 | await _barcodeReader.start( | 103 | await _barcodeReader.start( |
| 104 | startOptions, | 104 | startOptions, |
| @@ -184,7 +184,7 @@ class MobileScannerWeb extends MobileScannerPlatform { | @@ -184,7 +184,7 @@ class MobileScannerWeb extends MobileScannerPlatform { | ||
| 184 | 184 | ||
| 185 | await stop(); | 185 | await stop(); |
| 186 | await _barcodesController.close(); | 186 | await _barcodesController.close(); |
| 187 | - await _constraintsController.close(); | 187 | + await _settingsController.close(); |
| 188 | 188 | ||
| 189 | // Finally, remove the video element from the DOM. | 189 | // Finally, remove the video element from the DOM. |
| 190 | try { | 190 | try { |
| @@ -18,8 +18,8 @@ import 'package:web/web.dart' as web; | @@ -18,8 +18,8 @@ import 'package:web/web.dart' as web; | ||
| 18 | final class ZXingBarcodeReader extends BarcodeReader { | 18 | final class ZXingBarcodeReader extends BarcodeReader { |
| 19 | ZXingBarcodeReader(); | 19 | ZXingBarcodeReader(); |
| 20 | 20 | ||
| 21 | - /// The listener for media track constraints changes. | ||
| 22 | - void Function(web.MediaTrackConstraints)? _onMediaTrackConstraintsChanged; | 21 | + /// The listener for media track settings changes. |
| 22 | + void Function(web.MediaTrackSettings)? _onMediaTrackSettingsChanged; | ||
| 23 | 23 | ||
| 24 | /// The internal media stream track constraints delegate. | 24 | /// The internal media stream track constraints delegate. |
| 25 | final MediaTrackConstraintsDelegate _mediaTrackConstraintsDelegate = const MediaTrackConstraintsDelegate(); | 25 | final MediaTrackConstraintsDelegate _mediaTrackConstraintsDelegate = const MediaTrackConstraintsDelegate(); |
| @@ -139,10 +139,10 @@ final class ZXingBarcodeReader extends BarcodeReader { | @@ -139,10 +139,10 @@ final class ZXingBarcodeReader extends BarcodeReader { | ||
| 139 | 139 | ||
| 140 | await result?.toDart; | 140 | await result?.toDart; |
| 141 | 141 | ||
| 142 | - final web.MediaTrackConstraints? constraints = _mediaTrackConstraintsDelegate.getConstraints(stream); | 142 | + final web.MediaTrackSettings? settings = _mediaTrackConstraintsDelegate.getSettings(stream); |
| 143 | 143 | ||
| 144 | - if (constraints != null) { | ||
| 145 | - _onMediaTrackConstraintsChanged?.call(constraints); | 144 | + if (settings != null) { |
| 145 | + _onMediaTrackSettingsChanged?.call(settings); | ||
| 146 | } | 146 | } |
| 147 | } | 147 | } |
| 148 | } | 148 | } |
| @@ -193,8 +193,8 @@ final class ZXingBarcodeReader extends BarcodeReader { | @@ -193,8 +193,8 @@ final class ZXingBarcodeReader extends BarcodeReader { | ||
| 193 | } | 193 | } |
| 194 | 194 | ||
| 195 | @override | 195 | @override |
| 196 | - void setMediaTrackConstraintsListener(void Function(web.MediaTrackConstraints) listener) { | ||
| 197 | - _onMediaTrackConstraintsChanged ??= listener; | 196 | + void setMediaTrackSettingsListener(void Function(web.MediaTrackSettings) listener) { |
| 197 | + _onMediaTrackSettingsChanged ??= listener; | ||
| 198 | } | 198 | } |
| 199 | 199 | ||
| 200 | @override | 200 | @override |
| @@ -212,10 +212,10 @@ final class ZXingBarcodeReader extends BarcodeReader { | @@ -212,10 +212,10 @@ final class ZXingBarcodeReader extends BarcodeReader { | ||
| 212 | 212 | ||
| 213 | await _mediaTrackConstraintsDelegate.setFlashlightState(mediaStream, value); | 213 | await _mediaTrackConstraintsDelegate.setFlashlightState(mediaStream, value); |
| 214 | 214 | ||
| 215 | - final web.MediaTrackConstraints? constraints = _mediaTrackConstraintsDelegate.getConstraints(mediaStream); | 215 | + final web.MediaTrackSettings? settings = _mediaTrackConstraintsDelegate.getSettings(mediaStream); |
| 216 | 216 | ||
| 217 | - if (constraints != null) { | ||
| 218 | - _onMediaTrackConstraintsChanged?.call(constraints); | 217 | + if (settings != null) { |
| 218 | + _onMediaTrackSettingsChanged?.call(settings); | ||
| 219 | } | 219 | } |
| 220 | } | 220 | } |
| 221 | } | 221 | } |
| @@ -254,7 +254,7 @@ final class ZXingBarcodeReader extends BarcodeReader { | @@ -254,7 +254,7 @@ final class ZXingBarcodeReader extends BarcodeReader { | ||
| 254 | 254 | ||
| 255 | @override | 255 | @override |
| 256 | Future<void> stop() async { | 256 | Future<void> stop() async { |
| 257 | - _onMediaTrackConstraintsChanged = null; | 257 | + _onMediaTrackSettingsChanged = null; |
| 258 | _reader?.stopContinuousDecode.callAsFunction(); | 258 | _reader?.stopContinuousDecode.callAsFunction(); |
| 259 | _reader?.reset.callAsFunction(); | 259 | _reader?.reset.callAsFunction(); |
| 260 | _reader = null; | 260 | _reader = null; |
-
Please register or login to post a comment