File tree Expand file tree Collapse file tree 2 files changed +21
-4
lines changed Expand file tree Collapse file tree 2 files changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -69,3 +69,12 @@ class BrowserVersion {
69
69
/// The patch version number: "3" in "1.2.3".
70
70
final int patch;
71
71
}
72
+
73
+ bool isChrome129OrLater () {
74
+ if (lkPlatformIs (PlatformType .web) &&
75
+ [BrowserType .chrome, BrowserType .edge].contains (lkBrowser ())) {
76
+ final version = lkBrowserVersion ();
77
+ return version.major > 129 || (version.major == 129 && version.minor >= 0 );
78
+ }
79
+ return false ;
80
+ }
Original file line number Diff line number Diff line change @@ -88,9 +88,13 @@ class CameraCaptureOptions extends VideoCaptureOptions {
88
88
'facingMode' :
89
89
cameraPosition == CameraPosition .front ? 'user' : 'environment'
90
90
};
91
- if (deviceId != null ) {
91
+ if (deviceId != null && deviceId ! .isNotEmpty ) {
92
92
if (kIsWeb) {
93
- constraints['deviceId' ] = deviceId;
93
+ if (isChrome129OrLater ()) {
94
+ constraints['deviceId' ] = {'exact' : deviceId};
95
+ } else {
96
+ constraints['deviceId' ] = {'ideal' : deviceId};
97
+ }
94
98
} else {
95
99
constraints['optional' ] = [
96
100
{'sourceId' : deviceId}
@@ -331,9 +335,13 @@ class AudioCaptureOptions extends LocalTrackOptions {
331
335
}
332
336
}
333
337
334
- if (deviceId != null ) {
338
+ if (deviceId != null && deviceId ! .isNotEmpty ) {
335
339
if (kIsWeb) {
336
- constraints['deviceId' ] = deviceId;
340
+ if (isChrome129OrLater ()) {
341
+ constraints['deviceId' ] = {'exact' : deviceId};
342
+ } else {
343
+ constraints['deviceId' ] = {'ideal' : deviceId};
344
+ }
337
345
} else {
338
346
constraints['optional' ]
339
347
.cast <Map <String , dynamic >>()
You can’t perform that action at this time.
0 commit comments