Name Property

Summary
Gets the format's name.
Syntax
C#
C++/CLI
public string Name { get; } 
public: 
property String^ Name { 
   String^ get(); 
} 

Property Value

A string value representing the format's name.

Remarks

Gets the format's name.

Example
C#
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; 
   } 
} 
Requirements

Target Platforms

Help Version 22.0.2022.12.7
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.MediaFoundation Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.