public int AudioSamplesPerSecond {get;} Public ReadOnly Property AudioSamplesPerSecond As Integer public:property int AudioSamplesPerSecond {int get();}
An int value representing the audio samples per second.
Gets the audio samples per second value of the target audio type.
using Leadtools;using Leadtools.MediaFoundation;using LeadtoolsMediaFoundationExamples.Fixtures;public bool _result = false;public CaptureCtrlForm _form = new CaptureCtrlForm();public void AudioTypesExample(){// reference the capture controlCaptureCtrl capturectrl = _form.CaptureCtrl;try{// set an audio device first, you should use your audio device name hereif (capturectrl.AudioDevices["USB"] == null)throw new Exception("No USB audio device available");capturectrl.AudioDevices["USB"].Selected = true;// reference the target formats collectionTargetFormats formats = capturectrl.TargetFormats;// reference the target format objectTargetFormat tf = formats[TargetFormatType.WMV];// reference the target audio formats objectTargetAudioFormats taformats = tf.AudioFormats;// check the index using a name stringint i = taformats.IndexOf("{00000161-0000-0010-8000-00AA00389B71}");// Windows Media Audio (WMA)// get target audio format objectTargetAudioFormat taf = taformats[i];// make sure the target audio format object's name equals {00000161-0000-0010-8000-00AA00389B71}if (taf.Name == "{00000161-0000-0010-8000-00AA00389B71}"){// get target audio format friendly name, use it for view propose.string friendlyname = taf.FriendlyName;}elsethrow new Exception();// select ittaf.Selected = true;// get target audio types collectionTargetAudioTypes targetaudiotypes = taf.AudioTypes;// if target audio types larger than 0, loop through all of themif (targetaudiotypes.Count > 0){// enumerate through the list of audio types// demonstrating the target audio types propertiesforeach (TargetAudioType targetaudiotype in targetaudiotypes){// get name of the target type.string name = targetaudiotype.Name;// get friendly name of the target type.string friendlyname = targetaudiotype.FriendlyName;// set the audio type into the target format if:// AudioAvgBytesPerSecond == 24000 (192 kbps)// AudioBitsPerSample == 16// AudioNumChannels == 2 (stereo)// AudioSamplesPerSecond == 44100 Hzif (targetaudiotype.AudioAvgBytesPerSecond == 24000 &&targetaudiotype.AudioBitsPerSample == 16 &&targetaudiotype.AudioNumChannels == 2 &&targetaudiotype.AudioSamplesPerSecond == 44100){tf.SetAudioType(targetaudiotype);break;}}}// check if we have can capture video and audioif (capturectrl.IsModeAvailable(CaptureMode.VideoAndAudio)){// start the capture processcapturectrl.StartCapture(CaptureMode.VideoAndAudio);// we'll loop on the state and pump messages for this example.// but you should not need to if running from a Windows Forms application.while (capturectrl.State == CaptureState.Running)Application.DoEvents();}_result = true;}catch (Exception){_result = false;}}
Imports LeadtoolsImports Leadtools.MediaFoundationImports LeadtoolsMediaFoundationExamples.FixturesPublic _result As Boolean = FalsePublic _form As New CaptureCtrlForm()Public Sub AudioTypesExample()' reference the capture controlDim capturectrl As CaptureCtrl = _form.CaptureCtrlTry' set an audio device first, you should use your audio device name hereIf capturectrl.AudioDevices("USB") Is Nothing ThenThrow New Exception("No USB audio device available")End Ifcapturectrl.AudioDevices("USB").Selected = True' reference the target formats collectionDim formats As TargetFormats = capturectrl.TargetFormats' reference the target format objectDim tf As TargetFormat = formats(TargetFormatType.WMV)' reference the target audio formats objectDim taformats As TargetAudioFormats = tf.AudioFormats' check the index using a name stringDim i As Integer = taformats.IndexOf("{00000161-0000-0010-8000-00AA00389B71}") ' Windows Media Audio (WMA)' get target audio format objectDim taf As TargetAudioFormat = taformats(i)' make sure the target audio format object's name equals {00000161-0000-0010-8000-00AA00389B71}If taf.Name = "{00000161-0000-0010-8000-00AA00389B71}" Then' get target audio format friendly name, use it for view propose.Dim friendlyname As String = taf.FriendlyNameElseThrow New Exception()End If' select ittaf.Selected = True' get target audio types collectionDim targetaudiotypes As TargetAudioTypes = taf.AudioTypes' if target audio types larger than 0, loop through all of themIf targetaudiotypes.Count > 0 Then' enumerate through the list of audio types' demonstrating the target audio types propertiesFor Each targetaudiotype As TargetAudioType In targetaudiotypes' get name of the target type.Dim name As String = targetaudiotype.Name' get friendly name of the target type.Dim friendlyname As String = targetaudiotype.FriendlyName' set the audio type into the target format if:' AudioAvgBytesPerSecond == 24000 (192 kbps)' AudioBitsPerSample == 16' AudioNumChannels == 2 (stereo)' AudioSamplesPerSecond == 44100 HzIf targetaudiotype.AudioAvgBytesPerSecond = 24000 AndAlsotargetaudiotype.AudioBitsPerSample = 16 AndAlsotargetaudiotype.AudioNumChannels = 2 AndAlsotargetaudiotype.AudioSamplesPerSecond = 44100 Thentf.SetAudioType(targetaudiotype)Exit ForEnd IfNextEnd If' check if we have can capture video and audioIf capturectrl.IsModeAvailable(CaptureMode.VideoAndAudio) Then' start the capture processcapturectrl.StartCapture(CaptureMode.VideoAndAudio)' we'll loop on the state and pump messages for this example.' but you should not need to if running from a Windows Forms application.While capturectrl.State = CaptureState.RunningApplication.DoEvents()End WhileEnd If_result = TrueCatch generatedExceptionName As Exception_result = FalseEnd TryEnd Sub
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
