Gets the audio average bytes per second value of the target audio type.
public int AudioAvgBytesPerSecond {get;}
Public ReadOnly Property AudioAvgBytesPerSecond As Integer
public:
property int AudioAvgBytesPerSecond {
int get();
}
A value representing the audio average bytes per second.
Gets the audio average bytes 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 control
CaptureCtrl capturectrl = _form.CaptureCtrl;
try
{
// set an audio device first, you should use your audio device name here
if (capturectrl.AudioDevices["USB"] == null)
throw new Exception("No USB audio device available");
capturectrl.AudioDevices["USB"].Selected = true;
// reference the target formats collection
TargetFormats formats = capturectrl.TargetFormats;
// reference the target format object
TargetFormat tf = formats[TargetFormatType.WMV];
// reference the target audio formats object
TargetAudioFormats taformats = tf.AudioFormats;
// check the index using a name string
int i = taformats.IndexOf("{00000161-0000-0010-8000-00AA00389B71}");// Windows Media Audio (WMA)
// get target audio format object
TargetAudioFormat 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;
}
else
throw new Exception();
// select it
taf.Selected = true;
// get target audio types collection
TargetAudioTypes targetaudiotypes = taf.AudioTypes;
// if target audio types larger than 0, loop through all of them
if (targetaudiotypes.Count > 0)
{
// enumerate through the list of audio types
// demonstrating the target audio types properties
foreach (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 Hz
if (targetaudiotype.AudioAvgBytesPerSecond == 24000 &&
targetaudiotype.AudioBitsPerSample == 16 &&
targetaudiotype.AudioNumChannels == 2 &&
targetaudiotype.AudioSamplesPerSecond == 44100)
{
tf.SetAudioType(targetaudiotype);
break;
}
}
}
// check if we have can capture video and audio
if (capturectrl.IsModeAvailable(CaptureMode.VideoAndAudio))
{
// start the capture process
capturectrl.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 Leadtools
Imports Leadtools.MediaFoundation
Imports LeadtoolsMediaFoundationExamples.Fixtures
Public _result As Boolean = False
Public _form As New CaptureCtrlForm()
Public Sub AudioTypesExample()
' reference the capture control
Dim capturectrl As CaptureCtrl = _form.CaptureCtrl
Try
' set an audio device first, you should use your audio device name here
If capturectrl.AudioDevices("USB") Is Nothing Then
Throw New Exception("No USB audio device available")
End If
capturectrl.AudioDevices("USB").Selected = True
' reference the target formats collection
Dim formats As TargetFormats = capturectrl.TargetFormats
' reference the target format object
Dim tf As TargetFormat = formats(TargetFormatType.WMV)
' reference the target audio formats object
Dim taformats As TargetAudioFormats = tf.AudioFormats
' check the index using a name string
Dim i As Integer = taformats.IndexOf("{00000161-0000-0010-8000-00AA00389B71}") ' Windows Media Audio (WMA)
' get target audio format object
Dim 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.FriendlyName
Else
Throw New Exception()
End If
' select it
taf.Selected = True
' get target audio types collection
Dim targetaudiotypes As TargetAudioTypes = taf.AudioTypes
' if target audio types larger than 0, loop through all of them
If targetaudiotypes.Count > 0 Then
' enumerate through the list of audio types
' demonstrating the target audio types properties
For 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 Hz
If targetaudiotype.AudioAvgBytesPerSecond = 24000 AndAlso
targetaudiotype.AudioBitsPerSample = 16 AndAlso
targetaudiotype.AudioNumChannels = 2 AndAlso
targetaudiotype.AudioSamplesPerSecond = 44100 Then
tf.SetAudioType(targetaudiotype)
Exit For
End If
Next
End If
' check if we have can capture video and audio
If capturectrl.IsModeAvailable(CaptureMode.VideoAndAudio) Then
' start the capture process
capturectrl.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()
End While
End If
_result = True
Catch generatedExceptionName As Exception
_result = False
End Try
End Sub
Products |
Support |
Feedback: AudioAvgBytesPerSecond Property (TargetAudioType) - 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.