File tree Expand file tree Collapse file tree 4 files changed +21
-4
lines changed
samples/KristofferStrube.Blazor.WebAudio.WasmExample Expand file tree Collapse file tree 4 files changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -36,8 +36,12 @@ public async Task SetMediaStreamAudioSourceNode(AudioContext context)
3636 NoiseSuppression = NoiseSuppresion ,
3737 EchoCancellation = EchoCancellation ,
3838 AutoGainControl = false ,
39- DeviceId = SelectedAudioSource is null ? null : new ConstrainDomString ( SelectedAudioSource )
4039 } ;
40+ if ( SelectedAudioSource is not null )
41+ {
42+ mediaTrackConstraints . DeviceId = new ConstrainDOMStringParameters ( ) { Exact = SelectedAudioSource } ;
43+ }
44+
4145 MediaStream mediaStream = await mediaDevices . GetUserMediaAsync ( new MediaStreamConstraints ( ) { Audio = mediaTrackConstraints } ) ;
4246
4347 MediaDeviceInfo [ ] deviceInfos = await mediaDevices . EnumerateDevicesAsync ( ) ;
Original file line number Diff line number Diff line change 7676 EchoCancellation = true ,
7777 NoiseSuppression = true ,
7878 AutoGainControl = false ,
79- DeviceId = selectedAudioSource is null ? null : new ConstrainDomString (selectedAudioSource )
8079 };
80+
81+ if (selectedAudioSource is not null )
82+ {
83+ mediaTrackConstraints .DeviceId = new ConstrainDOMStringParameters () { Exact = selectedAudioSource };
84+ }
85+
8186 mediaStream = await mediaDevices .GetUserMediaAsync (new MediaStreamConstraints () { Audio = mediaTrackConstraints });
8287
8388 var deviceInfos = await mediaDevices .EnumerateDevicesAsync ();
Original file line number Diff line number Diff line change 8383 EchoCancellation = true ,
8484 NoiseSuppression = true ,
8585 AutoGainControl = false ,
86- DeviceId = selectedAudioSource is null ? null : new ConstrainDomString (selectedAudioSource )
8786 };
87+ if (selectedAudioSource is not null )
88+ {
89+ mediaTrackConstraints .DeviceId = new ConstrainDOMStringParameters () { Exact = selectedAudioSource };
90+ }
91+
8892 mediaStream = await mediaDevices .GetUserMediaAsync (new MediaStreamConstraints () { Audio = mediaTrackConstraints });
8993
9094 var deviceInfos = await mediaDevices .EnumerateDevicesAsync ();
Original file line number Diff line number Diff line change @@ -120,8 +120,12 @@ else
120120 EchoCancellation = true ,
121121 NoiseSuppression = true ,
122122 AutoGainControl = false ,
123- DeviceId = selectedAudioSource is null ? null : new ConstrainDomString (selectedAudioSource )
124123 };
124+ if (selectedAudioSource is not null )
125+ {
126+ mediaTrackConstraints .DeviceId = new ConstrainDOMStringParameters () { Exact = selectedAudioSource };
127+ }
128+
125129 mediaStream = await mediaDevices .GetUserMediaAsync (new MediaStreamConstraints () { Audio = mediaTrackConstraints });
126130
127131 var deviceInfos = await mediaDevices .EnumerateDevicesAsync ();
You can’t perform that action at this time.
0 commit comments