Embedding Video in a WinForms app - c#

I need to be able to embed and control the playback of an AVI file in a WinForms app, using C#. The video needs to be embedded in the form, not launched in a separate media player window.
What's the best approach to do this? I found the System.Media namespace, which sounded promising, but it appears that is only useful for sound.
Do I use DirectX to do this? MCI? Or some other approach?

You can use Media Player inside your Winform. This would been an easy way to do it.

The way i did it was, and I quote:
Right-click the Toolbox, and click Choose Items.
Note: If you do not see the Toolbox, click Toolbox on the View menu to
open it. The Customize Toolbox Items dialog box opens.
On the COM Components tab, select the Windows Media Player check box,
and then click OK.
The Windows Media Player control appears on the current Toolbox tab.
When you add the Windows Media Player control to the Toolbox, Visual
Studio automatically adds references to two libraries: AxWMPLib and
WMPLib. The next step is to add the control to the Windows Form.
To add the Windows Media Player control to a Windows Form
Drag the Windows Media Player control from the Toolbox to the Windows
Form.
In the Properties window, set the Dock property to Fill. You can do
this by clicking the center square.
Double-click the title bar of the form to add the default Load event
in the Code Editor.
Add the following code to the Form_Load event handler to load a video
when the application opens.
axWindowsMediaPlayer1.URL =
#"http://go.microsoft.com/fwlink/?LinkId=95772";
http://msdn.microsoft.com/en-us/library/bb383953(v=vs.90).aspx

I highly recommend this library:
http://directshownet.sourceforge.net/
It is a .NET wrapper around the DirectShow API.
(The sample apps should get you going very quickly.)
--Bruce

The suggestions from Daok and Brian Genisio are both good options. Let me add a third: DirectShow. Used to be part of DirectX but has now been promoted to the Windows SDK. There are many good C# sample applications to look at, and it gives complete control of the playback.

I would consider using the WPF media controls and just use the ElementHost to put your WPF control inside your WinForms app. I think you will get a much more rich experience.
See System.Windows.Forms.Integration for more information

Related

Dynamic form with resizing in C# .net

As a learning project in C# .net I am re-creating a Gnome 3 plugin for seeing who of the streamers you follow on Twitch is live. I have the settings form done, I am now working on the interface that is viewed from a click on the taskbar.
This is a rough image of what I want the interface to look like. When two or more streamers are live the interface would add another block and resize the form vertically similar to the menu for selecting a Wifi network in Windows.
What would be the best way for me to complete this?
My current thought is to maybe create a custom control and just place those inside a FlowLayoutPanel with some kind of code to change the vertical size of the form to match the added entries. Maybe this can be done without a custom control and be done with code inside a FlowLayoutPanel? I'm not too sure.
Ideally I would also have a click event in the panel for each streamer so I could then open a browser to their channel. A slight highlight would also be a plus (maybe change the background colour based on mouse hover).
Thanks in advance for any suggestions!

Left Menu Tabs Control in Windows Forms Application How can i get it? Its available in current controls?

i am building a C# application, i have explored its all controls but i cant find the left menu style which i usually see in software applications for example visual studio, i am attaching the image of what i need.
Please let me know how can i use it in my forms. I have used a tab menu control in visual studio, but it is not what i required, its tabs are vertical, but i want the exact like i shown in attachment. I think it requires some reference to add.
I don't think that control is available, which means you would have to make one yourself. Here is a link from someone that made one. I haven't tried it: Visual Studios "My Project" Tab Control
There is no such a control in the ToolBox by default. But you could create one for you.
Creat a user controller.
Added a SplitContainer and set Dock.Fill.
Add a FlowLayoutPanel to the Left panel. Add buttons or labels as you wish and implement the click event.

How would i make another application's child window into a tab? (C#)

For instance, I have an application that has a main window and then child windows inside of it.
http://screenshots.rd.to/sn/e3hek/sapienfullwindow.png
http://screenshots.rd.to/sn/e3hek/appscreen8.png
What i need is to grab each individual child window of that application, and display them as tabs in my application, or on a panel's handle.
I already have code to kidnap the application and put it into mine, and it works great.
MDI support is already present in the C#. So the first screenshot is using the MDI option.
The second screenshot is using tabbed windows. Now you have two options:
Use this opensource library DockPanelSuite which will let you have tabs in your application. something similar to visual studio interface. You can create forms and then tab it based on your needs. You can even dock them anywhere in the parent form by drag and drop. Just like in visual studio.
The second option is to create a form with tab control covering the whole windows. There you create tabs using the resource editor and hide/show based on the forms you want to display to the end user.
In my opinion, use the first option which gives you lot more customization. Also if you use the dockpanel, you can switch between the views shown in your first screenshot and second one. So user has better control as to how he wants to view. Dockpanel is free to use even in commerical apps and comes with source code. So you can either use the dll or directly incorporate the code in your application.

Application in the Taskbar

Can you give me an example on how to put my application form in the taskbar?
like Windows media player or Window search when minimize.
What you are looking for is creating an Application Desktop Toolbar (also known as AppBar). The main function you use to register your application window as an AppBar is SHAppBarMessage.
To get you started, you can look at this old appbar example with C++. If you want to do it in C#, there's a thread that discusses some details on how to do it in WPF. I am not aware of examples of how to do it with WinForms, but a quick search on the web should bring something.
Update: Actually, if you want a toolbar that sits on the taskbar, you need to implement a Deskband. Here's a sample DeskBand in C++ and here's a DeskBand in C#.
That's what happens when you don't touch a topic in a while. :-)
What this is really called is the 'System Tray' You want your app to have an icon in the windows system tray. Many languages provide this functionality.
Here are a few links:
http://www.codeguru.com/Cpp/COM-Tech/shell/icons/article.php/c1335
http://www.codeproject.com/KB/shell/systemtray.aspx

Rotate view of PDF on a WinForm

I have to display a PDF inside a winform (c# on .net 2.0 framework). For now, I am using the ActiveX PDF control provided by Adobe. I have to disable the entire control so that a user can't print or save via right-click or hotkeys. Unfortunately, many of the documents need to be rotated (just viewed, not permanently saved that way). I'd like to allow them to rotate the view by pressing a button control. I've tried enabling the control then programmatically sending the hotkeys (ctrl shift +) using SendKeys and SendInput but the timing issues make this a non-viable solution.
I've asked on the proper Adobe boards and they said it was not possible being that all of my clients will only have the reader version installed.
just rotate the control. put the control in a panel and rotate the panel or something.
I don't suppose you could put controls on the PDF that prevent saving and printing?

Categories