File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -789,9 +789,9 @@ export class WebCompat extends ContentFeature {
789
789
}
790
790
791
791
/**
792
- * Creates a valid MediaDeviceInfo object that passes instanceof checks
792
+ * Creates a valid MediaDeviceInfo or InputDeviceInfo object that passes instanceof checks
793
793
* @param {'videoinput' | 'audioinput' | 'audiooutput' } kind - The device kind
794
- * @returns {MediaDeviceInfo }
794
+ * @returns {MediaDeviceInfo | InputDeviceInfo }
795
795
*/
796
796
createMediaDeviceInfo ( kind ) {
797
797
// Create a simple object that looks like MediaDeviceInfo
@@ -818,8 +818,18 @@ export class WebCompat extends ContentFeature {
818
818
groupId : { writable : false , configurable : false }
819
819
} ) ;
820
820
821
- // Set the prototype to MediaDeviceInfo.prototype for instanceof checks
822
- Object . setPrototypeOf ( deviceInfo , MediaDeviceInfo . prototype ) ;
821
+ // Set the prototype based on device type
822
+ if ( kind === 'videoinput' || kind === 'audioinput' ) {
823
+ // Input devices should inherit from InputDeviceInfo.prototype if available
824
+ if ( typeof InputDeviceInfo !== 'undefined' && InputDeviceInfo . prototype ) {
825
+ Object . setPrototypeOf ( deviceInfo , InputDeviceInfo . prototype ) ;
826
+ } else {
827
+ Object . setPrototypeOf ( deviceInfo , MediaDeviceInfo . prototype ) ;
828
+ }
829
+ } else {
830
+ // Output devices inherit from MediaDeviceInfo.prototype
831
+ Object . setPrototypeOf ( deviceInfo , MediaDeviceInfo . prototype ) ;
832
+ }
823
833
824
834
return deviceInfo ;
825
835
}
You can’t perform that action at this time.
0 commit comments