|
调用ActiveX控件编写播放器时,遇到了不少问题!
发现MS.NET2003中缺少对一些动态链接库的引用! 在调用ActiveX等多媒体控件时,需要用到的MediaPlayer.dll 和 AxMediaPlayer.dll需要自己生成。 首先用下面的命令为媒体播放器控件:msdxm.ocx 生成 MediaPlayer.dll 和 AxMediaPlayer.dll。 aximp c:\winnt\system32\msdxm.ocx
而通常msdxm.ocx中的ActiveX控件都未注册! 再运行regsvr32 msdxm.ocx手动注册便生成需要的动态连接库文件. 再如图2所示,在项目中添加对MediaPlayer.dll 和 AxMediaPlayer.dll的引用; 并在程序中插入:using MediaPlayer便完成了整个调用过程!
播放器如图:

源程序代码如下:
using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using MediaPlayer;
namespace AdvancePlayer { /**//// <summary> /// Form1 的摘要说明。 /// </summary> public class Form1 : System.Windows.Forms.Form { private AxMediaPlayer.AxMediaPlayer axWindowsMediaPlayer1; private System.Windows.Forms.OpenFileDialog openFileDialog1; private System.Windows.Forms.MainMenu mainMenu1; private System.Windows.Forms.MenuItem menuItemOpen; private System.Windows.Forms.MenuItem menuItemClose; private System.Windows.Forms.MenuItem menuItemInitSize; private System.Windows.Forms.MenuItem menuItemFullScreen; private System.Windows.Forms.MenuItem menuItemShowAudioCtrl; private System.Windows.Forms.MenuItem menuItemShowPositionCtrl; private System.Windows.Forms.MenuItem menuItemShowTrackbarCtrl; private System.Windows.Forms.MenuItem menuItemFile; private System.Windows.Forms.MenuItem menuItemVideo; private System.Windows.Forms.MenuItem menuItemWindow;
/**//// <summary> /// 必需的设计器变量。 /// </summary> private System.ComponentModel.Container components = null;
public Form1() { // // Windows 窗体设计器支持所必需的 // InitializeComponent();
// // TODO: 在 InitializeComponent 调用后添加任何构造函数代码 // }
/**//// <summary> /// 清理所有正在使用的资源。 /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); }
[1] [2] [3] 下一页 |