Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Monday, May 25, 2009 7:25:09 AM(UTC)

Adam Boulad  
Guest

Groups: Guests
Posts: 3,022

Was thanked: 2 time(s) in 2 post(s)

The attached Visual Studio 2008 C# project uses our ltmmCapture control in a WPF program.
The application can preview the input from the available capture devices and capture a Video stream to an AVI file.
File Attachment(s):
CS_16_WPF_HostActivXControl.rar (19kb) downloaded 863 time(s).
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Wednesday, May 27, 2009 7:54:14 AM(UTC)

Adam Boulad  
Guest

Groups: Guests
Posts: 3,022

Was thanked: 2 time(s) in 2 post(s)

TUTORIAL: Host our multimedia ActiveX Controls in a WPF Application:

1- Start Visual Studio 2008.

2- Choose File => New Project, select C# and choose 'WPF Application' from the project templates. Name the project 'LEADPlayer_WPF'.

3- From the 'Solution Explorer' Menu, right-click on the 'LEADPlayer_WPF' solution and Add a new Project. Select the project type to be a 'Windows Forms Control Library' and name the project 'UserPlayerControl'.

4- Open the Toolbox, and add an ltmmPlayCtrl control to the UserControl form.

If the ltmmPlayCtrl does not exist in the Toolbox, do the following:

- Right-click in the Toolbox.
- Click Choose Items.
- Click the COM Components tab.
- Select the 'ltmmPlayCtrl' control.
- Click OK to accept the selection.

5- In Solution Explorer, right-click the UserControl1 file, and then click Rename. Rename the control to PlayControl.cs. If you are prompted to rename all references, click Yes.

6- Set the Dock property of the ltmmPlayCtrl control to Fill.

7- Right-click 'PlayControl.cs' in solution explorer, choose 'View Code' and add the following two methods after the PlayControl() function:

public void Stop ()
{
this.axltmmPlayCtrl1.Stop();
}
public void Play(string File)
{
this.axltmmPlayCtrl1.sourcefile = File;
this.axltmmPlayCtrl1.Run();            
}

8- Right-click 'Window1.xaml' and choose 'View Designer'.

9- Add a text box, two buttons and modify the buttons properties as follows:

Button1:
Control Name: btnPlay
Control Content: Play

Button2:
Control Name: btnStop
Control Content: Stop

10- Go to the Window1.xaml file in the XML editor and add a handler for the Window Loaded, btnPlay Click and btnStop events and give the grid tag a name. The code will be as follows:

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="402" Width="367" Loaded="Window_Loaded">






Play
Stop




11- Rebuild 'UserPlayerControl' and add the following references to 'LEADPlayer_WPF':

- UserPlayerControl.dll
- System.Windows.Forms.dll
- WindowsFormsIntegration.dll

12- In 'Window1.xaml.cs' add the following to the beginning of the file:

using System.Windows.Forms;
using System.Windows.Forms.Integration;
 
And define the following global variable:
UserPlayerControl.PlayControl uc1;

13- In the Window_Loaded event,  the following code

WindowsFormsHost host = new WindowsFormsHost();
uc1 = new UserPlayerControl.PlayControl();
host.Child = uc1;
DockPanel.SetDock(host, Dock.Top);
this.grid1.Children.Add(host);
textBox1.Text = "c:\\sample.avi";

14- In the btnPlay_Click event,  the following code
uc1.Play(textBox1.Text);

15- In the bntStop_Click event, add the following code:
uc1.Stop();

16- Compile and run.


The following post also shows how to add ltmmPlayCtrl to a C# WPF application:
http://support.leadtools.com/SupportPortal/CS/forums/25580/ShowPost.aspx

 
#3 Posted : Tuesday, March 6, 2012 2:55:45 AM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,326

Was thanked: 1 time(s) in 1 post(s)

I am attaching a C# 2010 WPF project that shows how you can use LEADTOOLS Multimedia .Net capture control with WPF and display the clock in real-time.

Note that I hosted our Leadtools.Multimedia.CaptureCtrl .Net control in WPF using the WindowsFormsHost Class. For more information, please see the following page:
http://msdn.microsoft.com/en-us/library/ms751761.aspx

Maen Badwan
LEADTOOLS Technical Support
File Attachment(s):
CsWPFMM175.zip (19kb) downloaded 864 time(s).
 
#4 Posted : Sunday, July 27, 2014 6:53:46 AM(UTC)

Walter  
Walter

Groups: Tech Support
Posts: 366

Thanks: 1 times
Was thanked: 4 time(s) in 4 post(s)

Please note that if you add one of the LEADTOOLS controls to the WindowsFormsHost control through XAML, you will need to handle the disposal of the control. If you do not, you may see a null reference exception when the application closes due to the WindowsFormsHost attempting to access the already disposed control. To prevent this, assign the Child element to null after getting the handle to the LEADTOOLS control. Here is some sample code to illustrate:

              Leadtools.Multimedia.PlayCtrl player = WinFormHost.Child as Leadtools.Multimedia.PlayCtrl;
              WinFormHost.Child = null;

              if (player != null)
              {
                 if (player.State == PlayState.Running)
                    player.Stop();

                 player.ResetSource();
                 player.Dispose();
              }
Walter Bates
Senior Support Engineer
LEAD Technologies, Inc.
LEAD Logo
 
#5 Posted : Monday, June 5, 2017 5:24:28 AM(UTC)

Walter  
Walter

Groups: Tech Support
Posts: 366

Thanks: 1 times
Was thanked: 4 time(s) in 4 post(s)

Attached is an updated Visual Studio 2017 project using LEADTOOLS 19.

The multimedia unlocking code is referenced in the main Form constructor. Update the global variable before running this project to remove the NAG message.

File Attachment(s):
CsWPFMM19.zip (9kb) downloaded 735 time(s).
Walter Bates
Senior Support Engineer
LEAD Technologies, Inc.
LEAD Logo
 
#6 Posted : Wednesday, July 3, 2019 11:13:44 AM(UTC)

Blaise  
Blaise

Groups: Registered, Tech Support, Administrators
Posts: 15

Was thanked: 1 time(s) in 1 post(s)

Updated to LEADTOOLS v20 with Visual Studio 2017.
Extract folder to "C:\LEADTOOLS 20\Examples\DotNet\CS\" to use this example.
File Attachment(s):
CsWPFMM20.zip (490kb) downloaded 70 time(s).
Blaise Kress
Developer Support Engineer
LEAD Technologies, Inc.
LEAD Logo
 
#7 Posted : Friday, October 27, 2023 1:24:04 PM(UTC)
Christopher

Groups: Registered, Tech Support, Administrators
Posts: 89

Was thanked: 4 time(s) in 4 post(s)

Updated to work with the LEADTOOLS v22 SDK.
Below is both an updated v22 CaptureCtrl implementation, as well as a v22 PlayCtrl implementation.

File Attachment(s):
CsWpfCaptCtrlMM22.zip (516kb) downloaded 7 time(s).

File Attachment(s):
CsWpfPlayCtrlMM22.zip (534kb) downloaded 5 time(s).


Chris Thompson
Developer Support Engineer
LEAD Technologies, Inc.

LEAD Logo
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.170 seconds.