LEADTOOLS Multimedia Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.31
Creating a Basic LEADTOOLS Multimedia Player Application
Take the following steps to create and run a multimedia player application using the LEADTOOLS Multimedia PlayCtrl control.

  1. Start Visual Studio .NET.
  2. Choose File->New->Project... from the menu.
  3. In the New Project dialog box, choose either "Visual C# Projects" or "Visual Basic Projects" in the Projects Type List, and choose "Windows Application " in the Templates List.
  4. Type the project name as "Multimedia Player" in the Project Name field, and then choose OK. If desired, type a new location for your project or select a directory using the Browse button, and then choose OK.
  5. In the "Solution Explorer" window, right-click on the "References" folder, and select "Add Reference..." from the context menu. In the "Add Reference" dialog box, select the ".NET" tab and select Leadtools.Multimedia and click OK. If this dll does not appear under the .NET tab, you will need select the Browse tab and add it from the "<LEADTOOLS_INSTALLDIR>\Bin\DotNet\Win32 " folder, by selecting the following DLL:
    • Leadtools.Multimedia.dll
    After browsing, click the Select button and then press the OK button to add the above DLL to the application.
  6. Make sure Form1 is in design view. Go to the toolbox (View->Toolbox) and drag and drop a PlayCtrl control on the form. NOTE: If you do not have PlayCtrl in your toolbox, select Tools->Choose Toolbox Items from the menu. Click Browse and then select Leadtools.Multimedia.dll from "<LEADTOOLS_INSTALLDIR>\Bin\DotNet\Win32" and then click Open and then click OK. After adding it to the form, set the following properties on the play control:
    Property Value
    Name _playctrl
    Anchor Top, Bottom, Left, Right
    AutoStart false
  7. Go to the toolbox (View->Toolbox) and drag and drop a ProgressBar control on the form (below the play control) and set the following properties:
    Property Value
    Name _progress
    Anchor Bottom, Left, Right
    Maximum 10000
    Step 1
  8. Go to the toolbox (View->Toolbox) and drag and drop a Button control to the bottom of the form and set the following properties:
    Property Value
    Name _buttonPlay
    Text Play
    Anchor Bottom, Right
  9. Switch Form1 to code view (right-click Form1 in the solution explorer then select View Code) and add the following lines at the beginning of the file:

    [Visual Basic]

                Imports Leadtools.Multimedia
                
    
    [C#]
                using Leadtools.Multimedia;
                
    
  10. Declare the following private variable:

    [Visual Basic]

                Private _sourceFile As String
                
    
    [C#]
                private string _sourceFile;
                
    
  11. Add an event handler to the Form1 Load event and code it as follows:

    [Visual Basic]

                Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
                   _sourceFile = @"<LEADTOOLS_INSTALLDIR>\Media\DaDa_DVD_MPEG2.mpg"
                End Sub
                
    
    [C#]
                private void Form1_Load(object sender, System.EventArgs e)
                {
                   _sourceFile = @"<LEADTOOLS_INSTALLDIR>\Media\DaDa_DVD_MPEG2.mpg";
                }
                
    
  12. Add an event handler to the _playctrl TrackingPositionChanged event and code it as follows:

    [Visual Basic]

                Private Sub _playctrl_TrackingPositionChanged(ByVal sender As System.Object, ByVal e As TrackingPositionChangedEventArgs) Handles _playctrl.TrackingPositionChanged
                   _progress.Value = e.position
                End Sub
                
    
    [C#]
                private void _playctrl_TrackingPositionChanged(object sender, TrackingPositionChangedEventArgs e)
                {
                   _progress.Value = e.position;
                }
                
    
  13. Add an event handler to the _buttonPlay Click event and code it as follows:

    [Visual Basic]

                Private Sub _buttonPlay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles _buttonPlay.Click
                   Try
                      _playctrl.SourceFile = _sourceFile
                      _playctrl.Run
                   Catch ex As Exception
                      MessageBox.Show(ex.Message)
                   End Try
                End Sub   
                
    
    [C#]
                private void _buttonPlay_Click(object sender, System.EventArgs e)
                {
                   try
                   {
                      _playctrl.SourceFile = _sourceFile;
                      _playctrl.Run();
                   }
                   catch (Exception ex)
                   {
                      MessageBox.Show(this, ex.Message);
                   }
                }
                
    
  14. Build, and Run the program to test it.