@@ -126,4 +126,64 @@ class MediaDevicesWeb extends MediaDevices {
126126 width: _mapConstraints['width' ],
127127 zoom: _mapConstraints['zoom' ]);
128128 }
129+
130+ @override
131+ Future <MediaDeviceInfo > selectAudioOutput (
132+ [AudioOutputOptions ? options]) async {
133+ try {
134+ final mediaDevices = html.window.navigator.mediaDevices;
135+ if (mediaDevices == null ) throw Exception ('MediaDevices is null' );
136+
137+ if (jsutil.hasProperty (mediaDevices, 'selectAudioOutput' )) {
138+ if (options != null ) {
139+ final arg = jsutil.jsify (options);
140+ final deviceInfo = await jsutil.promiseToFuture< html.MediaDeviceInfo > (
141+ jsutil.callMethod (mediaDevices, 'selectAudioOutput' , [arg]));
142+ return MediaDeviceInfo (
143+ kind: deviceInfo.kind,
144+ label: deviceInfo.label ?? '' ,
145+ deviceId: deviceInfo.deviceId ?? '' ,
146+ groupId: deviceInfo.groupId,
147+ );
148+ } else {
149+ final deviceInfo = await jsutil.promiseToFuture< html.MediaDeviceInfo > (
150+ jsutil.callMethod (mediaDevices, 'selectAudioOutput' , []));
151+ return MediaDeviceInfo (
152+ kind: deviceInfo.kind,
153+ label: deviceInfo.label ?? '' ,
154+ deviceId: deviceInfo.deviceId ?? '' ,
155+ groupId: deviceInfo.groupId,
156+ );
157+ }
158+ } else {
159+ throw UnimplementedError ('selectAudioOutput is missing' );
160+ }
161+ } catch (e) {
162+ throw 'Unable to selectAudioOutput: ${e .toString ()}' ;
163+ }
164+ }
165+
166+ @override
167+ set ondevicechange (Function (dynamic event)? listener) {
168+ try {
169+ final mediaDevices = html.window.navigator.mediaDevices;
170+ if (mediaDevices == null ) throw Exception ('MediaDevices is null' );
171+
172+ jsutil.setProperty (mediaDevices, 'ondevicechange' , listener);
173+ } catch (e) {
174+ throw 'Unable to set ondevicechange: ${e .toString ()}' ;
175+ }
176+ }
177+
178+ @override
179+ Function (dynamic event)? get ondevicechange {
180+ try {
181+ final mediaDevices = html.window.navigator.mediaDevices;
182+ if (mediaDevices == null ) throw Exception ('MediaDevices is null' );
183+
184+ jsutil.getProperty (mediaDevices, 'ondevicechange' );
185+ } catch (e) {
186+ throw 'Unable to get ondevicechange: ${e .toString ()}' ;
187+ }
188+ }
129189}
0 commit comments