Gets or sets the index of the selected AudioFormat item.
public int Selection {get; set;} Public Property Selection As Integer The zero-based index of the selected item; otherwise -1 if no item is selected.
Assigning a value to this property can raise an error exception. For more information, refer to the Error Codes.
using Leadtools;using Leadtools.MediaFoundation;using LeadtoolsMediaFoundationExamples.Fixtures;public CaptureCtrlForm _form = new CaptureCtrlForm();public bool _result = false;public void AudioFormatExample(){try{int count, freq = 0, bits = 0, channels = 0;int found, selected = -1;// reference the capture controlCaptureCtrl capturectrl = _form.CaptureCtrl;// set an audio device, use the name of your device hereif (capturectrl.AudioDevices["USB"] == null)throw new Exception("No USB audio device available");capturectrl.AudioDevices["USB"].Selected = true;// get count of available audio formatscount = capturectrl.AudioCaptureFormats.Count;// reset the current selection to -1capturectrl.AudioCaptureFormats.Selection = -1;// reference the audioformats propertyAudioFormats audioformats = capturectrl.AudioCaptureFormats;// enumerate formats and select oneforeach (AudioFormat af in audioformats){freq = af.SampleFrequency;bits = af.BitsPerSample;channels = af.Channels;// select the format if it matches some criteriaif (freq == 8000 && bits == 16 && channels == 2){af.Selected = true;break;}}// get the currently selected formatselected = audioformats.Selection;// find a format based on frequency, bits/channel and number of channelsfound = audioformats.IndexOf(8000, 8, 2);// our found format is not selected, so select itif (found != selected)audioformats.Selection = found;// get the new selected formatselected = audioformats.Selection;// set our result based on what we expect_result = (count > 0 && selected == found);}catch (Exception){_result = false;}}
Imports LeadtoolsImports Leadtools.MediaFoundationImports LeadtoolsMediaFoundationExamples.FixturesPublic _form As CaptureCtrlForm = New CaptureCtrlForm()Public _result As Boolean = FalsePublic Sub AudioFormatExample()TryDim count As Integer, freq As Integer = 0, bits As Integer = 0, channels As Integer = 0Dim found As Integer, selected As Integer = -1' reference the capture controlDim capturectrl As CaptureCtrl = _form.CaptureCtrl' set an audio device, use the name of your device hereIf capturectrl.AudioDevices("USB") Is Nothing ThenThrow New Exception("No USB audio device available")End Ifcapturectrl.AudioDevices("USB").Selected = True' get count of available audio formatscount = capturectrl.AudioCaptureFormats.Count' reset the current selection to -1capturectrl.AudioCaptureFormats.Selection = -1' reference the audioformats propertyDim audioformats As AudioFormats = capturectrl.AudioCaptureFormats' enumerate formats and select oneFor Each af As AudioFormat In audioformatsfreq = af.SampleFrequencybits = af.BitsPerSamplechannels = af.Channels' select the format if it matches some criteriaIf freq = 8000 AndAlso bits = 16 AndAlso channels = 2 Thenaf.Selected = TrueExit ForEnd IfNext af' get the currently selected formatselected = audioformats.Selection' find a format based on frequency, bits/channel and number of channelsfound = audioformats.IndexOf(8000, 8, 2)' our found format is not selected, so select itIf found <> selected Thenaudioformats.Selection = foundEnd If' get the new selected formatselected = audioformats.Selection' set our result based on what we expect_result = (count > 0 AndAlso selected = found)Catch e1 As Exception_result = FalseEnd TryEnd Sub
|
Products |
Support |
Feedback: Selection Property (AudioFormats) - Leadtools.MediaFoundation |
Introduction |
Help Version 19.0.2017.6.16
|

Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.