←Select platform

AudioRenderers Property (PlayCtrl)

Summary

Gets the registered audio renderers collection object.

Syntax

C#
VB
C++
public Leadtools.Mediafoundation.AudioRenderers AudioRenderers {get;} 
Public ReadOnly Property AudioRenderers As Leadtools.Mediafoundation.AudioRenderers 

Property Value

An AudioRenderers collection object representing the available audio renderers.

Remarks

Gets the registered audio renderers collection object. The AudioRenderers object is used to enumerate the available audio renderers, and to select a renderer for audio output.

Example

C#
VB
using Leadtools; 
using Leadtools.MediaFoundation; 
using LeadtoolsMediaFoundationExamples.Fixtures; 
 
public bool _result = false; 
public PlayCtrlForm _form = new PlayCtrlForm(); 
public PlayCtrl _playctrl; 
public TestCtrlSubForm _pcsbform; 
 
public void RenderersExample() 
{ 
   // reference the play control 
   _playctrl = _form.PlayCtrl; 
 
   // input file 
   string inFile = Path.Combine(LEAD_VARS.MediaDir, "PlayCtrl_SourceVideoOnly.avi"); 
 
   try 
   { 
      // create the sub form for renderers listbox 
      _pcsbform = new TestCtrlSubForm(); 
 
      _pcsbform.Load += new EventHandler(Form_Load); 
      _pcsbform.buttonRefresh.Click += new EventHandler(Refresh_Click); 
      _pcsbform.List.Click += new EventHandler(List_Click); 
 
      // set autostart to false 
      _playctrl.AutoStart = false; 
 
      // set our source media file 
      _playctrl.SourceFile = inFile; 
 
      // show the renderers form 
      _pcsbform.ShowDialog(); 
 
      // get the selected renderer index 
      int selectedRenderer = _playctrl.AudioRenderers.Selection; 
 
      // set the result to what we expect  
      _result = (_pcsbform.List.SelectedItem != null && _playctrl.AudioRenderers.Selection != -1); 
   } 
   catch (Exception) 
   { 
      _result = false; 
   } 
} 
 
void Form_Load(object sender, EventArgs e) 
{ 
   //  build the audio renderer list 
   EnumerateRenderers(_playctrl.AudioRenderers, _pcsbform.List); 
} 
 
void List_Click(object sender, EventArgs e) 
{ 
   //  select the audio renderer 
   SelectRenderer(_playctrl.AudioRenderers, _pcsbform.List); 
} 
 
void Refresh_Click(object sender, EventArgs e) 
{ 
   //  refresh audio renderers 
   RefreshRenderers(_playctrl.AudioRenderers, _pcsbform.List); 
} 
 
void EnumerateRenderers(AudioRenderers Renderers, ListBox List) 
{ 
   //  Build the renderers list box 
   int Selected = -1; 
 
   // empty the list box 
   List.Items.Clear(); 
 
   // add the available audio renderers to the list box 
   for (int i = 0; (i <= (Renderers.Count - 1)); i++) 
   { 
      List.Items.Add(Renderers[i]); 
      if (Renderers[i].Selected) 
      { 
         Selected = i; 
      } 
   } 
   //  highlight the current selection 
   List.SelectedIndex = Selected; 
} 
 
void RefreshRenderers(AudioRenderers Renderers, ListBox List) 
{ 
   string SelectedName = string.Empty; 
 
   //  save the currently selected renderer's name 
   if (Renderers.Selection >= 0) 
      SelectedName = Renderers[Renderers.Selection].FriendlyName; 
 
   //  refresh the renderer collection 
   Renderers.Refresh(); 
 
   //  if there was a previously selected renderer, reselect it 
   if (SelectedName != string.Empty) 
      Renderers.Selection = Renderers.IndexOf(SelectedName); 
 
   //  rebuild the listbox 
   EnumerateRenderers(Renderers, List); 
} 
 
void SelectRenderer(AudioRenderers Renderers, ListBox List) 
{ 
   //  select the highlighted renderer 
   Renderers.Selection = Renderers.IndexOf(List.Items[List.SelectedIndex] as Renderer); 
} 
 
static class LEAD_VARS 
{ 
   public const string MediaDir = @"C:\Program Files (x86)\LEAD Technologies\LEADTOOLS 19\Media"; 
} 
Imports Leadtools 
Imports Leadtools.MediaFoundation 
Imports LeadtoolsMediaFoundationExamples.Fixtures 
 
Public _result As Boolean = False 
Public _form As PlayCtrlForm = New PlayCtrlForm() 
Public _playctrl As PlayCtrl 
Public _pcsbform As TestCtrlSubForm 
 
Public Sub RenderersExample() 
   ' reference the play control 
   _playctrl = _form.PlayCtrl 
 
   ' input file 
   Dim inFile As String = Path.Combine(LEAD_VARS.MediaDir, "PlayCtrl_SourceVideoOnly.avi") 
 
   Try 
      ' create the sub form for renderers listbox 
      _pcsbform = New TestCtrlSubForm() 
 
      AddHandler _pcsbform.Load, AddressOf Form_Load 
      AddHandler _pcsbform.buttonRefresh.Click, AddressOf Refresh_Click 
      AddHandler _pcsbform.List.Click, AddressOf List_Click 
 
      ' set autostart to false 
      _playctrl.AutoStart = False 
 
      ' set our source media file 
      _playctrl.SourceFile = inFile 
 
      ' show the renderers form 
      _pcsbform.ShowDialog() 
 
      ' get the selected renderer index 
      Dim selectedRenderer As Integer = _playctrl.AudioRenderers.Selection 
 
      ' set the result to what we expect  
      _result = (Not _pcsbform.List.SelectedItem Is Nothing AndAlso _playctrl.AudioRenderers.Selection <> -1) 
   Catch e1 As Exception 
      _result = False 
   End Try 
End Sub 
 
Private Sub Form_Load(ByVal sender As Object, ByVal e As EventArgs) 
   '  build the audio renderer list 
   EnumerateRenderers(_playctrl.AudioRenderers, _pcsbform.List) 
End Sub 
 
Private Sub List_Click(ByVal sender As Object, ByVal e As EventArgs) 
   '  select the audio renderer 
   SelectRenderer(_playctrl.AudioRenderers, _pcsbform.List) 
End Sub 
 
Private Sub Refresh_Click(ByVal sender As Object, ByVal e As EventArgs) 
   '  refresh audio renderers 
   RefreshRenderers(_playctrl.AudioRenderers, _pcsbform.List) 
End Sub 
 
Private Sub EnumerateRenderers(ByVal Renderers As AudioRenderers, ByVal List As ListBox) 
   '  Build the renderers list box 
   Dim Selected As Integer = -1 
 
   ' empty the list box 
   List.Items.Clear() 
 
   ' add the available audio renderers to the list box 
   Dim i As Integer = 0 
   Do While (i <= (Renderers.Count - 1)) 
      List.Items.Add(Renderers(i)) 
      If Renderers(i).Selected Then 
         Selected = i 
      End If 
      i += 1 
   Loop 
   '  highlight the current selection 
   List.SelectedIndex = Selected 
End Sub 
 
Private Sub RefreshRenderers(ByVal Renderers As AudioRenderers, ByVal List As ListBox) 
   Dim SelectedName As String = String.Empty 
 
   '  save the currently selected renderer's name 
   If Renderers.Selection >= 0 Then 
      SelectedName = Renderers(Renderers.Selection).FriendlyName 
   End If 
 
   '  refresh the renderer collection 
   Renderers.Refresh() 
 
   '  if there was a previously selected renderer, reselect it 
   If SelectedName <> String.Empty Then 
      Renderers.Selection = Renderers.IndexOf(SelectedName) 
   End If 
 
   '  rebuild the listbox 
   EnumerateRenderers(Renderers, List) 
End Sub 
 
Private Sub SelectRenderer(ByVal Renderers As AudioRenderers, ByVal List As ListBox) 
   '  select the highlighted renderer 
   Renderers.Selection = Renderers.IndexOf(TryCast(List.Items(List.SelectedIndex), Renderer)) 
End Sub 
 
Public NotInheritable Class LEAD_VARS 
   Public Const MediaDir As String = "C:\Program Files (x86)\LEAD Technologies\LEADTOOLS 19\Media" 
End Class 

Requirements

Target Platforms

Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
Leadtools.MediaFoundation Assembly
Click or drag to resize