Introduction Usually whenever I see a question that asks about inserting any kind of advanced graphics into a Windows Form, I tend to recommend inserting a WPF element using ElementHost. But if your requirement is just to include the ability to play a video file (giving the user the option to start, pause, stop, etc) then I think that using the Windows Media Player and embedding an instance into a form is a good way to go. Of course, if your video needs get more complex then WPF will probably be your next port of call.
Apr 20, 2011 - You need to add a COM reference to Windows Media Player wmp.dll in your main project. Add Windows media Player to WPF Application. Let's run the application to have test ride. The above figure is the FolderBrowserDialog, opened when clicked for Browse. The media files are selected on the left hand side after Folder Path selection. When the media item is selected from the ListBox, it would start playing.
How to Embed the Windows Media Player The first step is to find the Media Player as it isn’t included in the Visual Studio Toolbox by default. Right-click on the Toolbox list and select the Choose Items option: In the dialog box that then appears, click on the COM Components tab.
Navigate down and select the Windows Media Player. Click OK to add it to the Toolbox: Now you can drag an instance of the player onto a form.
Once you have done this, you can either set the required properties via the Properties pane as usual or you can access a separate dialog box by right-clicking on the player and selecting the Properties menu item from the context menu. This offers a range of options, the most important initially of course being the location of the video file to be played. You can set this to a file on your hard drive or – more usually if you want external users to be able to see it – a URL. One point to note about this control is that it doesn’t stream the video, so it has to buffer the file before playing begins. If, like me, you have a very slow broadband connection then you will need to improve the user experience by keeping their attention while the file loads, or breaking the file into smaller chunks and downloading them individually.
Otherwise you’ll have to look into some of the other possibilities that do allow streaming, such as DirectShow or Silverlight’s MediaElement or something like Jeremiah Morrill’s VideoRendererElement solution, which you can see on.