public int Selection { get; set; } Public Property Selection As Integer
The zero-based index of the selected item; otherwise -1 if no item selected.
Gets or sets the zero-based index of the currently selected Renderer item. Assignment could raise an error exception. For more information, refer to the Error Codes.
using Leadtools;using Leadtools.MediaFoundation;using LeadtoolsMediaFoundationExamples.Fixtures;public bool _result = false;public CaptureCtrlForm _form = new CaptureCtrlForm();public CaptureCtrl _capturectrl;public void AudioRenderersExample(){// output filestring outFile = Path.Combine(LEAD_VARS.MediaDir, "CaptureCtrl_AudioRenderersExample.avi");// reference the capture control_capturectrl = _form.CaptureCtrl;try{// set the source video device, select using your device name hereif (_capturectrl.VideoDevices["USB"] == null)throw new Exception("No USB video device available");_capturectrl.VideoDevices["USB"].Selected = true;// set the target file_capturectrl.TargetFile = outFile;// reference the audio renderers collectionAudioRenderers ar = _capturectrl.AudioRenderers;// get the current selectionint currSelection = ar.Selection;// loop through the capture control's registered audio renderersforeach (Renderer r in ar){// select by renderer friendly nameif (r.FriendlyName == "Default DirectSound Device" && r != ar[currSelection]){// select itr.Selected = true;break;}// select by renderer name (device name)if (r.Name == @"@device:cm:{E0F158E1-CB04-11D0-BD4E-00A0C911CE86}\Default DirectSound Device" && r != ar[currSelection]){// select itr.Selected = true;break;}}// check the new selectionint newSelection = ar.Selection;// set the result to what we expect_result = (currSelection != newSelection);// set the started event handler_capturectrl.Started += new EventHandler(CaptureCtrl_Started);// run the capture_capturectrl.StartCapture(CaptureMode.Video);}catch (Exception){_result = false;}// 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();}public void CaptureCtrl_Started(object sender, EventArgs e){// stop the capture_capturectrl.StopCapture();}static class LEAD_VARS{public const string MediaDir = @"C:\LEADTOOLS21\Media";}
Imports LeadtoolsImports Leadtools.MediaFoundationImports LeadtoolsMediaFoundationExamples.FixturesPublic _result As Boolean = FalsePublic _form As New CaptureCtrlForm()Public _capturectrl As CaptureCtrlPublic Sub AudioRenderersExample()' output fileDim outFile As String = Path.Combine(LEAD_VARS.MediaDir, "CaptureCtrl_AudioRenderersExample.avi")' reference the capture control_capturectrl = _form.CaptureCtrlTry' set the source video device, select using your device name hereIf _capturectrl.VideoDevices("USB") Is Nothing ThenThrow New Exception("No USB video device available")End If_capturectrl.VideoDevices("USB").Selected = True' set the target file_capturectrl.TargetFile = outFile' reference the audio renderers collectionDim ar As AudioRenderers = _capturectrl.AudioRenderers' get the current selectionDim currSelection As Integer = ar.Selection' loop through the capture control's registered audio renderersFor Each r As Renderer In ar' select by renderer friendly nameIf r.FriendlyName = "Default DirectSound Device" AndAlso Not r Is ar(currSelection) Then' select itr.Selected = TrueExit ForEnd If' select by renderer name (device name)If r.Name = "@device:cm:{E0F158E1-CB04-11D0-BD4E-00A0C911CE86}\Default DirectSound Device" _AndAlso Not r Is ar(currSelection) Then' select itr.Selected = TrueExit ForEnd IfNext' check the new selectionDim newSelection As Integer = ar.Selection' set the result to what we expect_result = (currSelection <> newSelection)' set the started event handlerAddHandler _capturectrl.Started, AddressOf CaptureCtrl_Started' run the capture_capturectrl.StartCapture(CaptureMode.Video)Catch generatedExceptionName As Exception_result = FalseEnd Try' 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 SubPublic Sub CaptureCtrl_Started(ByVal sender As Object, ByVal e As EventArgs)' stop the capture_capturectrl.StopCapture()End SubPublic NotInheritable Class LEAD_VARSPublic Const MediaDir As String = "C:\LEADTOOLS21\Media"End Class
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
