1. Background
In the past few days, an old friend asked me to make a small software program to play videos in WinForm. In the impression, Microsoft has a WM control that can be used directly.
2 Implementation Method 2.1 Microsoft grassroots
The simplest way is to directly use Microsoft's WM control and integrate it through COM. The procedure is as follows:
L toolbox reference
N create a new Tab page in the toolbox and name it Windows Media Player (randomly named). Right-click it and select it, as shown in
N select the Com panel, find the control shown in, and reference it.
N after the reference is successful, as shown in. This control already exists in the toolbox. Drag this control directly to the page.
L code development
The code is relatively simple, as shown in. Detailed code is provided in the download file
2.2
The player used in impressions should be traced back to the university. at that time, Kingsoft film overlord and hero RealPlay player were used. then it was a storm video. Till now, I have been using this player. I personally feel very good. now, let's get down to the truth.
Once installed successfully, the Com component is also installed for development and use by programmers. in fact, it also has another function, which can be used to play videos on Web pages. It should be implemented in the form of a cab package. If you are interested, you can study it. the method of referencing Microsoft WM is the same. shows its name in Com.
L toolbox reference
After successful reference, as shown in
L code development
The code is actually quite simple. it is worth noting that do not directly drag this control to the page, otherwise the page will be very stuck, or even VS will be stuck. as shown in, declare a page variable and load it to the GroupBox control.
Other code is shown in. Detailed code is in the downloaded file.
Appendix: After Com is successfully referenced, DLL reference is shown in
Source code file, downloaded from Baidu online storage
Http://pan.baidu.com/s/1o6LTx6U