Imports Leadtools
Imports Leadtools.Multimedia
Imports LeadtoolsMultimediaExamples.Fixtures
Public _result As Boolean = False
Public _form As PlayCtrlForm = New PlayCtrlForm()
Public _playctrl As PlayCtrl
Public Sub IsAudioStreamEnabledExample()
   ' reference the play control
   _playctrl = _form.PlayCtrl
   Dim inFile As String = Path.Combine(LEAD_VARS.MediaDir, "VIDEO_TS\VIDEO_TS.IFO")
   Try
      ' set auto start off
      _playctrl.AutoStart = False
      ' use DVDSource
      _playctrl.UseDVDSource = True
      ' set the input file
      _playctrl.SourceFile = inFile
      ' check the DVD options
      DvdInfoCheck()
      ' play it
      _playctrl.Run()
   Catch e1 As Exception
      _result = False
   End 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.
   Do While _playctrl.State = PlayState.Running
      Application.DoEvents()
   Loop
End Sub
' check DVD properties and info
Private Sub DvdInfoCheck()
   Dim bstrVal As String
   Dim val As Integer
   Dim button As Integer = _playctrl.DvdController.CurrentButton
   val = _playctrl.DvdController.GetButtonWidth(button)
   val = _playctrl.DvdController.GetButtonHeight(button)
   val = _playctrl.DvdController.GetButtonLeft(button)
   val = _playctrl.DvdController.GetButtonTop(button)
   val = _playctrl.DvdController.DefaultMenuLanguage
   _playctrl.DvdController.DefaultMenuLanguage = 1033
   val = _playctrl.DvdController.GetNumberOfChapters(0)
   val = _playctrl.DvdController.TotalTitleTime
   Dim tcFlags As DVDTimecodeFlags = _playctrl.DvdController.TitleTimecodeFlags
   val = _playctrl.DvdController.CurrentAngle
   If _playctrl.DvdController.AnglesAvailable > 1 Then
      _playctrl.DvdController.CurrentAngle = 2
   End If
   Dim userOp As DVDValidUserOp = _playctrl.DvdController.CurrentUOPS
   Dim audioLang As Long = _playctrl.DvdController.GetAudioLanguage(0)
   val = _playctrl.DvdController.CurrentAudioStream
   If _playctrl.DvdController.AudioStreamsAvailable > 1 Then
      _playctrl.DvdController.CurrentAudioStream = 2
   End If
   val = _playctrl.DvdController.CurrentTime
   val = _playctrl.DvdController.CurrentVolume
   val = _playctrl.DvdController.VolumesAvailable
   val = _playctrl.DvdController.TitlesAvailable
   Dim enabled As Boolean = _playctrl.DvdController.IsAudioStreamEnabled(0)
   val = _playctrl.DvdController.DefaultAudioLanguage
   _playctrl.DvdController.SelectDefaultAudioLanguage(1033, DVDAudioLangExt.Captions)
   Dim directory As String = _playctrl.DvdController.DVDDirectory
   val = _playctrl.DvdController.CurrentSubpictureStream
   val = _playctrl.DvdController.SubpictureStreamsAvailable
   If (val > 1) Then
      _playctrl.DvdController.CurrentSubpictureStream = 1
   End If
   val = _playctrl.DvdController.DefaultSubpictureLanguage
   _playctrl.DvdController.SelectDefaultSubpictureLanguage(1033, DVDSubpictureLangExt.Caption_Normal)
   val = _playctrl.DvdController.CurrentTitle
   Dim subPicLangExt As DVDSubpictureLangExt = _playctrl.DvdController.DefaultSubpictureLanguageExt
   Dim audioLangExt As DVDAudioLangExt = _playctrl.DvdController.DefaultAudioLanguageExt
   Dim subpicLang As Long = _playctrl.DvdController.GetSubpictureLanguage(0)
   Dim subPicStream As Boolean = _playctrl.DvdController.IsSubpictureStreamEnabled(0)
   val = _playctrl.DvdController.GetDVDTextLanguageLCID(0)
   val = _playctrl.DvdController.DVDTextNumberOfLanguages
   val = _playctrl.DvdController.GetGPRM(0)
   _playctrl.DvdController.SetGPRM(0, 1)
   val = _playctrl.DvdController.GetDVDTextNumberOfStrings(0)
   val = _playctrl.DvdController.ButtonsAvailable
   val = _playctrl.DvdController.PlayerParentalLevel
   val = _playctrl.DvdController.PlayerParentalCountry
   Dim ppCountry As String = String.Format("{0}{1}", CChar(ChrW(val And &HFF)), CChar(ChrW(val >> 8)))
   If ppCountry <> "US" Then
      val = CInt(AscW("U"c))
      val += (CInt(AscW("S"c)) << 8)
      _playctrl.DvdController.SelectParentalCountry(val, "user", "pwd")
   End If
   val = _playctrl.DvdController.GetTitleParentalLevels(-1)
   _playctrl.DvdController.SelectParentalLevel(9, "user", "pwd")
   Dim domain As DVDDomain = _playctrl.DvdController.CurrentDomain
   Dim diskSide As DVDDiscSide = _playctrl.DvdController.CurrentDiscSide
   val = _playctrl.DvdController.CurrentChapter
   Dim textStrType As DVDTextStringType = _playctrl.DvdController.GetDVDTextStringType(0, 0)
   If (Not _playctrl.DvdController.SubpictureOn) Then
      _playctrl.DvdController.SubpictureOn = True
   End If
   val = _playctrl.DvdController.GetSPRM(0)
   bstrVal = _playctrl.DvdController.GetDVDTextString(0, 0)
   bstrVal = _playctrl.DvdController.DVDUniqueID
End Sub
' menu event helpers for DVD navigation and control
Private Sub mnAcceptParentalLevelChange_Click()
   _playctrl.DvdController.AcceptParentalLevelChange(True)
End Sub
Private Sub mnActivateAtPosition_Click()
   _playctrl.DvdController.ActivateAtPosition(10, 10)
End Sub
Private Sub mnActivateButton_Click()
   _playctrl.DvdController.ActivateButton()
End Sub
Private Sub mnChangeDVDRegion_Click()
   _playctrl.DvdController.ChangeDVDRegion(_form)
End Sub
Private Sub mnNotifyParentalLevelChange_Click()
   _playctrl.DvdController.NotifyParentalLevelChange(True)
End Sub
Private Sub mnPause_Click()
   _playctrl.DvdController.Pause(True)
End Sub
Private Sub mnPlayAtInTitle_Click()
   _playctrl.DvdController.PlayAtTimeInTitle(1, 10000000)
End Sub
Private Sub mnPlayAtTime_Click()
   _playctrl.DvdController.PlayAtTime(10000000)
End Sub
Private Sub mnPlaybackword_Click()
   _playctrl.DvdController.PlayBackwards(5)
End Sub
Private Sub mnPlayChapter_Click()
   _playctrl.DvdController.PlayChapter(1)
End Sub
Private Sub mnPlaychapterautostop_Click()
   _playctrl.DvdController.PlayChaptersAutoStop(1, 2, 5)
End Sub
Private Sub mnPlaychapterintitle_Click()
   _playctrl.DvdController.PlayChapterInTitle(1, 3)
End Sub
Private Sub mnPlayfowrward_Click()
   _playctrl.DvdController.PlayForwards(5)
End Sub
Private Sub mnPlayNextChapter_Click()
   _playctrl.DvdController.PlayNextChapter()
End Sub
Private Sub mnPlayperiod_Click()
   _playctrl.DvdController.PlayPeriodInTitleAutoStop(1, 30, 120)
End Sub
Private Sub mnPlayPrevChapter_Click()
   _playctrl.DvdController.PlayPrevChapter()
End Sub
Private Sub mnPlaytitle_Click()
   _playctrl.DvdController.PlayTitle(1)
End Sub
Private Sub mnReplayChapter_Click()
   _playctrl.DvdController.ReplayChapter()
End Sub
Private Sub mnResume_Click()
   _playctrl.DvdController.Resume()
End Sub
Private Sub mnReturnfromsubmenu_Click()
   _playctrl.DvdController.ReturnFromSubmenu()
End Sub
Private Sub mnSelectAndActivateButton_Click()
   _playctrl.DvdController.SelectAndActivateButton(1)
End Sub
Private Sub mnSelectAtPosition_Click()
   _playctrl.DvdController.SelectAtPosition(10, 10)
End Sub
Private Sub mnSelectButton_Click()
   _playctrl.DvdController.SelectButton(1)
End Sub
Private Sub mnSelectRelativeButton_Click()
   _playctrl.DvdController.SelectRelativeButton(DVDRelativeButton.Right)
End Sub
Private Sub mnSetDVDDirectory_Click()
   _playctrl.DvdController.DVDDirectory = "e:\video_ts"
End Sub
Private Sub mnShowMenu_Click()
   _playctrl.DvdController.ShowMenu(DVDMenuId.Root)
End Sub
Private Sub mnStillOff_Click()
   _playctrl.DvdController.StillOff()
End Sub
Private Sub mnStop_Click()
   _playctrl.DvdController.Stop()
End Sub
Public NotInheritable Class LEAD_VARS
Public Const MediaDir As String = "C:\Program Files (x86)\LEAD Technologies\LEADTOOLS 19\Media"
End Class
             
   
     
            using Leadtools;
using Leadtools.Multimedia;
using LeadtoolsMultimediaExamples.Fixtures;
public bool _result = false;
public PlayCtrlForm _form = new PlayCtrlForm();
public PlayCtrl _playctrl;
public void IsAudioStreamEnabledExample()
{
   // reference the play control
   _playctrl = _form.PlayCtrl;
   string inFile =Path.Combine(LEAD_VARS.MediaDir,@"VIDEO_TS\VIDEO_TS.IFO");
   try
   {
      // set auto start off
      _playctrl.AutoStart = false;
      // use DVDSource
      _playctrl.UseDVDSource = true;
      // set the input file
      _playctrl.SourceFile = inFile;
      // check the DVD options
      DvdInfoCheck();
      // play it
      _playctrl.Run();
   }
   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 (_playctrl.State == PlayState.Running)
      Application.DoEvents();
}
// check DVD properties and info
private void DvdInfoCheck()
{
   string bstrVal;
   int val;
   int button = _playctrl.DvdController.CurrentButton;
   val = _playctrl.DvdController.GetButtonWidth(button);
   val = _playctrl.DvdController.GetButtonHeight(button);
   val = _playctrl.DvdController.GetButtonLeft(button);
   val = _playctrl.DvdController.GetButtonTop(button);
   val = _playctrl.DvdController.DefaultMenuLanguage;
   _playctrl.DvdController.DefaultMenuLanguage = 1033;
   val = _playctrl.DvdController.GetNumberOfChapters(0);
   val = _playctrl.DvdController.TotalTitleTime;
   DVDTimecodeFlags tcFlags = _playctrl.DvdController.TitleTimecodeFlags;
   val = _playctrl.DvdController.CurrentAngle;
   if (_playctrl.DvdController.AnglesAvailable > 1)
      _playctrl.DvdController.CurrentAngle = 2;
   DVDValidUserOp userOp = _playctrl.DvdController.CurrentUOPS;
   long audioLang = _playctrl.DvdController.GetAudioLanguage(0);
   val = _playctrl.DvdController.CurrentAudioStream;
   if (_playctrl.DvdController.AudioStreamsAvailable > 1)
      _playctrl.DvdController.CurrentAudioStream = 2;
   val = _playctrl.DvdController.CurrentTime;
   val = _playctrl.DvdController.CurrentVolume;
   val = _playctrl.DvdController.VolumesAvailable;
   val = _playctrl.DvdController.TitlesAvailable;
   bool enabled = _playctrl.DvdController.IsAudioStreamEnabled(0);
   val = _playctrl.DvdController.DefaultAudioLanguage;
   _playctrl.DvdController.SelectDefaultAudioLanguage(1033, DVDAudioLangExt.Captions);
   string directory = _playctrl.DvdController.DVDDirectory;
   val = _playctrl.DvdController.CurrentSubpictureStream;
   val = _playctrl.DvdController.SubpictureStreamsAvailable;
   if ((val > 1))
   {
      _playctrl.DvdController.CurrentSubpictureStream = 1;
   }
   val = _playctrl.DvdController.DefaultSubpictureLanguage;
   _playctrl.DvdController.SelectDefaultSubpictureLanguage(1033, DVDSubpictureLangExt.Caption_Normal);
   val = _playctrl.DvdController.CurrentTitle;
   DVDSubpictureLangExt subPicLangExt = _playctrl.DvdController.DefaultSubpictureLanguageExt;
   DVDAudioLangExt audioLangExt = _playctrl.DvdController.DefaultAudioLanguageExt;
   long subpicLang = _playctrl.DvdController.GetSubpictureLanguage(0);
   bool subPicStream = _playctrl.DvdController.IsSubpictureStreamEnabled(0);
   val = _playctrl.DvdController.GetDVDTextLanguageLCID(0);
   val = _playctrl.DvdController.DVDTextNumberOfLanguages;
   val = _playctrl.DvdController.GetGPRM(0);
   _playctrl.DvdController.SetGPRM(0, 1);
   val = _playctrl.DvdController.GetDVDTextNumberOfStrings(0);
   val = _playctrl.DvdController.ButtonsAvailable;
   val = _playctrl.DvdController.PlayerParentalLevel;
   val = _playctrl.DvdController.PlayerParentalCountry;
   string ppCountry = string.Format("{0}{1}", (char)(val & 0xFF), (char)(val >> 8));
   if (ppCountry != "US")
   {
      val = (int)'U';
      val += ((int)'S' << 8);
      _playctrl.DvdController.SelectParentalCountry(val, "user", "pwd");
   }
   val = _playctrl.DvdController.GetTitleParentalLevels(-1);
   _playctrl.DvdController.SelectParentalLevel(9, "user", "pwd");
   DVDDomain domain = _playctrl.DvdController.CurrentDomain;
   DVDDiscSide diskSide = _playctrl.DvdController.CurrentDiscSide;
   val = _playctrl.DvdController.CurrentChapter;
   DVDTextStringType textStrType = _playctrl.DvdController.GetDVDTextStringType(0, 0);
   if (!_playctrl.DvdController.SubpictureOn)
      _playctrl.DvdController.SubpictureOn = true;
   val = _playctrl.DvdController.GetSPRM(0);
   bstrVal = _playctrl.DvdController.GetDVDTextString(0, 0);
   bstrVal = _playctrl.DvdController.DVDUniqueID;
}
// menu event helpers for DVD navigation and control
private void mnAcceptParentalLevelChange_Click()
{
   _playctrl.DvdController.AcceptParentalLevelChange(true);
}
private void mnActivateAtPosition_Click()
{
   _playctrl.DvdController.ActivateAtPosition(10, 10);
}
private void mnActivateButton_Click()
{
   _playctrl.DvdController.ActivateButton();
}
private void mnChangeDVDRegion_Click()
{
   _playctrl.DvdController.ChangeDVDRegion(_form);
}
private void mnNotifyParentalLevelChange_Click()
{
   _playctrl.DvdController.NotifyParentalLevelChange(true);
}
private void mnPause_Click()
{
   _playctrl.DvdController.Pause(true);
}
private void mnPlayAtInTitle_Click()
{
   _playctrl.DvdController.PlayAtTimeInTitle(1, 10000000);
}
private void mnPlayAtTime_Click()
{
   _playctrl.DvdController.PlayAtTime(10000000);
}
private void mnPlaybackword_Click()
{
   _playctrl.DvdController.PlayBackwards(5);
}
private void mnPlayChapter_Click()
{
   _playctrl.DvdController.PlayChapter(1);
}
private void mnPlaychapterautostop_Click()
{
   _playctrl.DvdController.PlayChaptersAutoStop(1, 2, 5);
}
private void mnPlaychapterintitle_Click()
{
   _playctrl.DvdController.PlayChapterInTitle(1, 3);
}
private void mnPlayfowrward_Click()
{
   _playctrl.DvdController.PlayForwards(5);
}
private void mnPlayNextChapter_Click()
{
   _playctrl.DvdController.PlayNextChapter();
}
private void mnPlayperiod_Click()
{
   _playctrl.DvdController.PlayPeriodInTitleAutoStop(1, 30, 120);
}
private void mnPlayPrevChapter_Click()
{
   _playctrl.DvdController.PlayPrevChapter();
}
private void mnPlaytitle_Click()
{
   _playctrl.DvdController.PlayTitle(1);
}
private void mnReplayChapter_Click()
{
   _playctrl.DvdController.ReplayChapter();
}
private void mnResume_Click()
{
   _playctrl.DvdController.Resume();
}
private void mnReturnfromsubmenu_Click()
{
   _playctrl.DvdController.ReturnFromSubmenu();
}
private void mnSelectAndActivateButton_Click()
{
   _playctrl.DvdController.SelectAndActivateButton(1);
}
private void mnSelectAtPosition_Click()
{
   _playctrl.DvdController.SelectAtPosition(10, 10);
}
private void mnSelectButton_Click()
{
   _playctrl.DvdController.SelectButton(1);
}
private void mnSelectRelativeButton_Click()
{
   _playctrl.DvdController.SelectRelativeButton(DVDRelativeButton.Right);
}
private void mnSetDVDDirectory_Click()
{
   _playctrl.DvdController.DVDDirectory = @"e:\video_ts";
}
private void mnShowMenu_Click()
{
   _playctrl.DvdController.ShowMenu(DVDMenuId.Root);
}
private void mnStillOff_Click()
{
   _playctrl.DvdController.StillOff();
}
private void mnStop_Click()
{
   _playctrl.DvdController.Stop();
}
static class LEAD_VARS
{
public const string MediaDir = @"C:\Program Files (x86)\LEAD Technologies\LEADTOOLS 19\Media";
}