AddMenuTitle Method

Summary
Adds a new title to the menu.
Syntax
C#
C++/CLI
[DispIdAttribute(7)] 
void AddMenuTitle(  
   string Title, 
   int Index 
) 
[DispIdAttribute(7)] 
void AddMenuTitle(  
   String^ Title, 
   int Index 
)  

Parameters

Title
Character string that contains the title text that will appear in the menu.

Index
A zero-based index of the title

S_OK if the function was successful.

<>S_OK if an error occurred. Refer to the Error Codes or the HRESULT error codes in the DirectShow documentation.

Remarks

Adds a new title to the menu. The title list can be modified at any time before writing the menu. A maximum of 36 titles can be added. Calling the LTDvdWriter.AddMenuTitle method with an existing index will not make an update: it will insert a new title at the specified index and shift the list down.

Menu writing should be the last step in a DVD image authoring process. Writing the menu first will cause an error and if a new title is written after the menu has been written, then the menu will be destroyed.

Any multimedia file can be used as the menu background, including a single page image, a multipage image, or a video. All menus require a background video. To add menus to the DVD image, perform the following steps:

  1. Add a menu title by calling the LTDvdWriter.AddMenuTitle method.
  2. Set the LTDvdWriter.TitleMenu property to true.
  3. Convert the background image for the menu. This is a standard DVD conversion graph. Only the video will be used for the menu background.
  4. Set the LTDvdWriter.TitleMenu property to false to close the "menu write" mode. This merges the menu subtitle information with the background video and modifies the DVD image.
Example
C#
using Leadtools.Multimedia; 
using LeadtoolsMultimediaExamples.Fixtures; 
 
 
public bool _result = false; 
public ConvertCtrlForm _form = new ConvertCtrlForm(); 
 
private ConvertCtrl _convertCtrl = null; 
private LTDvdWriter _dvdWriter = null; 
 
public void DvdWriterExample() 
{ 
   // reference the convert control 
   _convertCtrl = _form.ConvertCtrl; 
 
   // source files for DVD content 
   string inFile1 = Path.Combine(LEAD_VARS.MediaDir, "DaDa_CMP.avi"); 
   string inFile2 = Path.Combine(LEAD_VARS.MediaDir, "DaDa_CMW.avi"); 
   string inFile3 = Path.Combine(LEAD_VARS.MediaDir, "DaDa_J2K.avi"); 
   string inFile4 = Path.Combine(LEAD_VARS.MediaDir, "Test_VideoStabilizer.avi"); 
   string backgroundImageFile = Path.Combine(LEAD_VARS.ImagesDir, "cannon.jpg"); 
   string outFile = Path.Combine(LEAD_VARS.MediaDir, "ConvertCtrl_DvdWriterExample_DVD"); 
 
   try 
   { 
      _dvdWriter = null; 
 
      _convertCtrl.Preview = true; 
      _convertCtrl.PreviewVisible = true; 
 
      // setup the converter 
      _convertCtrl.TargetFormat = TargetFormatType.DVD; 
      _convertCtrl.VideoCompressors.Mpeg2.Selected = true; 
      _convertCtrl.AudioCompressors.MpegAudio.Selected = true; 
 
      // Create a DVD image with 2 titles, each contains 2 chapters:  
      // Source video 
      _convertCtrl.SourceFile = inFile1; 
 
      // Destination image folder 
      _convertCtrl.TargetFile = outFile; 
 
      // Retrieve the DVD Writer interface  
      _dvdWriter = _convertCtrl.GetSubObject(ConvertObject.Sink) as LTDvdWriter; 
 
      _dvdWriter.RemoveAllMenuTitles(); 
      _dvdWriter.MenulessTitlePlay = false; 
 
      // Set the TitleBreak property to false.  
      // This will prevent the title from being written immediately after the conversion 
      _dvdWriter.TitleBreak = false; 
 
      _dvdWriter.AddMenuTitle("Title 1", -1); 
 
      // Write the first chapter in the first title 
      _convertCtrl.StartConvert(); 
 
      while (_convertCtrl.State != ConvertState.Stopped) 
         Application.DoEvents(); 
 
      _convertCtrl.ResetSource(); 
 
      int highPart = 0; 
      int lowPart = _dvdWriter.GetBytesWritten(out highPart); 
      Int64 written = highPart << 32 | lowPart; 
 
      _convertCtrl.SourceFile = inFile2; 
      _convertCtrl.StartConvert(); 
 
      while (_convertCtrl.State != ConvertState.Stopped) 
         Application.DoEvents(); 
 
      _convertCtrl.ResetSource(); 
 
      // Prepare for the second title 
      // Set the TitleBreak property to TRUE, so the current title can be flushed 
      _dvdWriter.TitleBreak = true; 
 
      // Disable Overwrite so the title will be appended to an existing dvd image 
      _dvdWriter.Overwrite = false; 
      _dvdWriter.MenulessTitlePlay = false; 
 
      // Set the TitleBreak property to FALSE.  
      // This will prevent the title from being written immediately after the conversion 
      _dvdWriter.TitleBreak = false; 
      _dvdWriter.AddMenuTitle("Title 2", -1); 
 
      // Write the first chapter in the second title 
      _convertCtrl.SourceFile = inFile3; 
      _convertCtrl.StartConvert(); 
 
      while (_convertCtrl.State != ConvertState.Stopped) 
         Application.DoEvents(); 
 
      _convertCtrl.ResetSource(); 
 
      // Write the second chapter in the second title 
      _convertCtrl.SourceFile = inFile4; 
      _convertCtrl.StartConvert(); 
 
      while (_convertCtrl.State != ConvertState.Stopped) 
         Application.DoEvents(); 
 
      _convertCtrl.ResetSource(); 
 
      // Close the second title 
      _dvdWriter.TitleBreak = true; 
 
      _dvdWriter.TitleMenu = true; 
      _dvdWriter.MenuLoop = true; 
      _dvdWriter.MenulessTitlePlay = false; 
 
      // Write the second chapter in the second title 
      _convertCtrl.SourceFile = backgroundImageFile; 
      ChangeStillImageDuration(1.0); 
 
      _convertCtrl.StartConvert(); 
 
      while (_convertCtrl.State != ConvertState.Stopped) 
         Application.DoEvents(); 
 
      _convertCtrl.ResetSource(); 
 
      _dvdWriter.TitleMenu = false; 
      _dvdWriter.Overwrite = false; 
 
      _convertCtrl.ResetTarget(); 
      _convertCtrl.ResetSource(); 
 
      // done, free COM object 
      Marshal.ReleaseComObject(_dvdWriter); 
      _dvdWriter = null; 
 
      // set the result  
      _result = true; 
   } 
   catch (Exception ex) 
   { 
      _result = false; 
   } 
} 
 
private void ChangeStillImageDuration(double duration) 
{ 
   ILTStlImgRd pStlImgRd; 
 
   try 
   { 
      pStlImgRd = _convertCtrl.GetSubObject(ConvertObject.SourceFilter) as ILTStlImgRd; 
      if (pStlImgRd != null) 
      { 
         // get the current menu duration 
         double currentDuration; 
         currentDuration = _convertCtrl.Duration; 
 
         if (currentDuration * 2 <= duration) 
            pStlImgRd.Loop = (int)(duration / currentDuration + 0.5); 
      } 
   } 
   catch 
   { 
   } 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
   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.

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