使用DirectX技术实现播放,需要引用系统的 C:/WINNT/system32/quartz.dll
是从CodeProject上看来的。前一阵看到有人需要这样的代码,所以贴出来共享一下。
using System;;
using System.Collections;;
using System.ComponentModel;;
using System.Drawing;;
using System.Data;;
using System.Windows.Forms;;
using QuartzTypeLib;;
namespace Greystar.FrameWork.ToolKits
{
/// 〈summary〉
/// FrmTV 的摘要说明。
/// 〈/summary〉
public class FrmTV : System.Windows.Forms.UserControl
{
private System.Windows.Forms.ToolBar toolBar1;;
private System.Windows.Forms.ToolBarButton toolBarButton1;;
private System.Windows.Forms.ToolBarButton toolBarButton2;;
private System.Windows.Forms.ToolBarButton toolBarButton3;;
private System.Windows.Forms.Panel panel1;;
private System.Windows.Forms.ImageList imageList1;;
private System.Windows.Forms.Timer timer1;;
private System.Windows.Forms.ToolBarButton toolBarButton4;;
private System.ComponentModel.IContainer components;;
private const int WM_APP = 0x8000;;
private const int WM_GRAPHNOTIFY = WM_APP + 1;;
private const int EC_COMPLETE = 0x01;;
private const int WS_CHILD = 0x40000000;;
private const int WS_CLIPCHILDREN = 0x2000000;;
private FilgraphManager m_objFilterGraph = null;;
private IBasicAudio m_objBasicAudio = null;;
private IVideoWindow m_objVideoWindow = null;;
private IMediaEvent m_objMediaEvent = null;;
private IMediaEventEx m_objMediaEventEx = null;;
private IMediaPosition m_objMediaPosition = null;;
private IMediaControl m_objMediaControl = null;;
private System.Windows.Forms.StatusBar statusBar1;;
private System.Windows.Forms.StatusBarPanel statusBarPanel1;;
private System.Windows.Forms.StatusBarPanel statusBarPanel2;;
private System.Windows.Forms.StatusBarPanel statusBarPanel3;;
enum MediaStatus { None, Stopped, Paused, Running };;
private MediaStatus m_CurrentStatus = MediaStatus.None;;
public FrmTV()
{
// 该调用是 Windows.Forms 窗体设计器所必需的。
InitializeComponent();;
// TODO: 在 InitializeComponent 调用后添加任何初始化
}
public FrmTV(EnvDTE._DTE dte,string workpath)
{
InitializeComponent();;
this.mDTE=dte;;
this.mWorkPath=workpath;;
}
private _DTE mDTE=null;;
public _DTE DTE
{
set
{
mDTE=value;;
}
get
{
return mDTE;;
}
}
//工作目录
private string mWorkPath=null;;
public string WorkPath
{
set
{
this.mWorkPath=value;;
}
}
/// 〈summary〉
/// 清
是从CodeProject上看来的。前一阵看到有人需要这样的代码,所以贴出来共享一下。
using System;;
using System.Collections;;
using System.ComponentModel;;
using System.Drawing;;
using System.Data;;
using System.Windows.Forms;;
using QuartzTypeLib;;
namespace Greystar.FrameWork.ToolKits
{
/// 〈summary〉
/// FrmTV 的摘要说明。
/// 〈/summary〉
public class FrmTV : System.Windows.Forms.UserControl
{
private System.Windows.Forms.ToolBar toolBar1;;
private System.Windows.Forms.ToolBarButton toolBarButton1;;
private System.Windows.Forms.ToolBarButton toolBarButton2;;
private System.Windows.Forms.ToolBarButton toolBarButton3;;
private System.Windows.Forms.Panel panel1;;
private System.Windows.Forms.ImageList imageList1;;
private System.Windows.Forms.Timer timer1;;
private System.Windows.Forms.ToolBarButton toolBarButton4;;
private System.ComponentModel.IContainer components;;
private const int WM_APP = 0x8000;;
private const int WM_GRAPHNOTIFY = WM_APP + 1;;
private const int EC_COMPLETE = 0x01;;
private const int WS_CHILD = 0x40000000;;
private const int WS_CLIPCHILDREN = 0x2000000;;
private FilgraphManager m_objFilterGraph = null;;
private IBasicAudio m_objBasicAudio = null;;
private IVideoWindow m_objVideoWindow = null;;
private IMediaEvent m_objMediaEvent = null;;
private IMediaEventEx m_objMediaEventEx = null;;
private IMediaPosition m_objMediaPosition = null;;
private IMediaControl m_objMediaControl = null;;
private System.Windows.Forms.StatusBar statusBar1;;
private System.Windows.Forms.StatusBarPanel statusBarPanel1;;
private System.Windows.Forms.StatusBarPanel statusBarPanel2;;
private System.Windows.Forms.StatusBarPanel statusBarPanel3;;
enum MediaStatus { None, Stopped, Paused, Running };;
private MediaStatus m_CurrentStatus = MediaStatus.None;;
public FrmTV()
{
// 该调用是 Windows.Forms 窗体设计器所必需的。
InitializeComponent();;
// TODO: 在 InitializeComponent 调用后添加任何初始化
}
public FrmTV(EnvDTE._DTE dte,string workpath)
{
InitializeComponent();;
this.mDTE=dte;;
this.mWorkPath=workpath;;
}
private _DTE mDTE=null;;
public _DTE DTE
{
set
{
mDTE=value;;
}
get
{
return mDTE;;
}
}
//工作目录
private string mWorkPath=null;;
public string WorkPath
{
set
{
this.mWorkPath=value;;
}
}
/// 〈summary〉
/// 清