ToggleClosedCaptioning Method

Summary
Switches the state of the close captioning mode on or off.
Syntax
C#
C++/CLI
public virtual void ToggleClosedCaptioning() 
public: 
virtual void ToggleClosedCaptioning();  
Remarks

This is a convenient method to turn the close captioning mode on and off. If the method fails, an error is raised. For more information, refer to the Error Codes.

Example
C#
using Leadtools; 
using Leadtools.Multimedia; 
using LeadtoolsMultimediaExamples.Fixtures; 
 
 
public bool _result = false; 
public CaptureCtrlForm _form = new CaptureCtrlForm(); 
public CaptureCtrl _capturectrl; 
 
public void ClosedCaptioningExample() 
{ 
   // reference the capture control 
   _capturectrl = _form.CaptureCtrl; 
 
   // output file names 
   string outFile = Path.Combine(LEAD_VARS.MediaDir, "CaptureCtrl_ClosedCaptioningExample_DVD"); 
 
   try 
   { 
      // try to find a Digital tuner, use your device name here 
      if (_capturectrl.VideoDevices["Analog"] == null) 
         throw new Exception("No Analog video device available"); 
 
      _capturectrl.VideoDevices["Analog"].Selected = true; 
 
      // select video and audio compressors 
      _capturectrl.VideoCompressors.Mpeg2.Selected = true; 
      _capturectrl.AudioCompressors.AC3.Selected = true; 
 
      // set the target format to MPEG2 program 
      _capturectrl.TargetFormat = TargetFormatType.MPEG2Program; 
 
      if (_capturectrl.HasDialog(CaptureDlg.TargetFormat)) 
         _capturectrl.ShowDialog(CaptureDlg.TargetFormat, _form); 
 
      // tune to a channel with closed captions 
      _capturectrl.TVTuner.SetChannel(28, -1, -1); 
 
      // set the target file 
      _capturectrl.TargetFile = outFile; 
 
      // enable the preview 
      _capturectrl.Preview = true; 
 
      // check whether closed captioning is enabled 
      if (_capturectrl.ClosedCaptionAvailable 
         && _capturectrl.ClosedCaptioning == false) 
      { 
         // try to toggle closed captioning  
         _capturectrl.ToggleClosedCaptioning(); 
 
         // set the result to what we expect 
         if (_capturectrl.ClosedCaptioning) 
            _result = true; 
 
         // get the previewing cc state 
         bool _previewCC = _capturectrl.PreviewingClosedCaption; 
      } 
 
      // check whether we can capture video 
      if (_capturectrl.IsModeAvailable(CaptureMode.VideoAndAudio)) 
      { 
         _capturectrl.TimeLimit = 30;      // just 30 seconds of capture time 
         _capturectrl.UseTimeLimit = true; 
 
         // 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; 
   } 
 
   // 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(); 
} 
 
static class LEAD_VARS 
{ 
   public const string MediaDir = @"C:\LEADTOOLS22\Media"; 
} 
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.Multimedia Assembly

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