一、新建windows应用程序项目,添加vedioForm窗体

二、在com组件中找到windows media player,添加引用

三、代码如下:

 public partial class VedioForm : Form
{
private AxWMPLib.AxWindowsMediaPlayer axWindowsMediaPlayer1;
public VedioForm()
{
InitializeComponent();
InitVedio();
}
private void VedioForm_Load(object sender, EventArgs e)
{
InitVedioUrl();
InitEvent();
}
//初始化播放控件
private void InitVedio()
{
this.axWindowsMediaPlayer1 = new AxWMPLib.AxWindowsMediaPlayer();
this.axWindowsMediaPlayer1.Enabled = true;
this.axWindowsMediaPlayer1.Location = new System.Drawing.Point(, );
this.axWindowsMediaPlayer1.Name = "axWindowsMediaPlayer1";
this.axWindowsMediaPlayer1.Size = new System.Drawing.Size(, );
this.axWindowsMediaPlayer1.TabIndex = ;
this.Controls.Add(this.axWindowsMediaPlayer1);
}
//初始化播放控件的视频文件地址
protected void InitVedioUrl()
{
this.axWindowsMediaPlayer1.URL = @"D:/Vedio/default.wmv";
} protected void InitEvent()
{
axWindowsMediaPlayer1.StatusChange += new EventHandler(axWindowsMediaPlayer1_StatusChange);
} //通过控件的状态改变,来实现视频循环播放
protected void axWindowsMediaPlayer1_StatusChange(object sender, EventArgs e)
{
/* 0 Undefined Windows Media Player is in an undefined state.(未定义)
1 Stopped Playback of the current media item is stopped.(停止)
2 Paused Playback of the current media item is paused. When a media item is paused, resuming playback begins from the same location.(停留)
3 Playing The current media item is playing.(播放)
4 ScanForward The current media item is fast forwarding.
5 ScanReverse The current media item is fast rewinding.
6 Buffering The current media item is getting additional data from the server.(转换)
7 Waiting Connection is established, but the server is not sending data. Waiting for session to begin.(暂停)
8 MediaEnded Media item has completed playback. (播放结束)
9 Transitioning Preparing new media item.
10 Ready Ready to begin playing.(准备就绪)
11 Reconnecting Reconnecting to stream.(重新连接)
*/
//判断视频是否已停止播放
if ((int)axWindowsMediaPlayer1.playState == )
{
//停顿2秒钟再重新播放
System.Threading.Thread.Sleep();
//重新播放
axWindowsMediaPlayer1.Ctlcontrols.play();
}
}
}

[基本属性]

URL:string 可以指定媒体位置

enableContextMenu:Boolean 显示/不显示播放位置的右键菜单

fullScreen:boolean 全屏显示

stretchToFit:boolean 非全屏状态时是否伸展到最佳大小

uMode:string 播放器的模式,full:有下面的控制条; none:只有播放部份没有控制条

playState:integer 当前控件状态,状态变化时会触发OnStatusChange事件

[controls]

可通过WindowsMediaPlayer.controls对播放器进行控制并取得相关的一些信息:

controls.play; 播放

controls.stop; 停止

controls.pause; 暂停

controls.currentPosition:Double 当前播放进度

controls.currentPositionString:string 时间格式的字符串 “0:32″

[currentMedia]

可以通过WindowsMediaPlayer.currentMedia取得当前媒体的信息

currentMedia.duration Double 总长度

currentMedia.durationString 时间格式的字符串 “4:34″

[settings]

可以通过WindowsMediaPlayer.settings对播放器进行设置,包括音量和声道等。

settings.volume:integer 音量 (0-100)

settings.balance:integer 声道,通过它应该可以进行立体声、左声道、右声道的控制。

Media Player Player.playState获取播放状态事件

Value State Description

0 Undefined Windows Media Player is in an undefined state.(未定义)

1 Stopped Playback of the current media item is stopped.(停止)

2 Paused Playback of the current media item is paused. When a media item is paused, resuming playback begins from the same location.(停留)

3 Playing The current media item is playing.(播放)

4 ScanForward The current media item is fast forwarding.

5 ScanReverse The current media item is fast rewinding.

6 Buffering The current media item is getting additional data from the server.(转换)

7 Waiting Connection is established, but the server is not sending data. Waiting for session to begin.(暂停)

8 MediaEnded Media item has completed playback. (播放结束)

9 Transitioning Preparing new media item.

10 Ready Ready to begin playing.(准备就绪)

11 Reconnecting Reconnecting to stream.(重新连接)

原文:http://blog.csdn.net/slimboy123/archive/2010/06/23/5688616.aspx

windows media player 播放视频的更多相关文章

  1. Windows Media Player播放视频导致程序闪退

    在有的电脑上发现,使用Windows Media Player组件播放视频导致程序闪退. 发现是显卡问题,独立显卡换成集成显卡 解决: 打开显卡控制面板->管理3D设置->集成图形-> ...

  2. C# Winform使用Windows Media Player播放多媒体整理

    一.简单使用示例步骤 1.添加Windows Media Player 组件当前是系统的 Com组件 工具箱>右键“选择项”>选择Com组件 2.控件拖拽到桌面,使用 private vo ...

  3. winform中的Windows Media Player播放器设置

    namespace WindowsMediaPlayer{ public partial class Form1 : Form { Form2 form2;//声明from2窗体 public For ...

  4. windows media player 中播放pls的方法

    windows media player目前只能播放 wpl 和 asm格式的列表文件.而linux下mplayer和vlc支持的pls,很遗憾没法支持. 不过,老外写了个“open pls in w ...

  5. C#中Windows Media Player控件使用实例|方法

    Windows Media Player控件Windows Media Player是一种媒体播放器,可以播放当前最流行的音频.视频文件和大多数混合型的多媒体文件.为了便于程序的开发,Visual S ...

  6. win7自带windows media player 已停止工作

    解决方法如下: 在计算机开始,菜单找到控制面板 ,然后打开程序和功能,选择打开或关闭window功能,媒体功能.再取消windows Media Center Windows MediaPlayer选 ...

  7. Windows Media Player安装了却不能播放网页上的视频

    前段时间遇到Windows Media Player安装了却不能播放网页上的视频的问题,在网上查找资料时,发现大部分资料都没能解决我这个问题.偶尔试了网上一牛人的方法,后来竟然解决了.现在再找那个网页 ...

  8. winform播放视频(windows media player)

    1.找到windows media player 工具箱常规下边右键,右键弹窗点击“选择项”,选择工具箱窗口点击“COM组件”,找到 Windows Media Player 勾选,点击确定 2.使用 ...

  9. [Winform]Media Player播放控制面板控制,单击事件截获

    摘要 在项目中有这样的一个需求,需要在一台宣传机器上循环播放一段视频,并在体验的用户单击鼠标左键的时候推出全屏,可以让用户体验电脑的其它功能. 解决方案 考虑到都是windows系统的,所以采用了wi ...

随机推荐

  1. TensorFlow中卷积

    CNN中的卷积核及TensorFlow中卷积的各种实现 声明: 1. 我和每一个应该看这篇博文的人一样,都是初学者,都是小菜鸟,我发布博文只是希望加深学习印象并与大家讨论. 2. 我不确定的地方用了“ ...

  2. 毕设三: spark与phoenix集成插入数据/解析json数组

    需求:将前些日子采集的评论存储到hbase中 思路: 先用fastjson解析评论,然后构造rdd,最后使用spark与phoenix交互,把数据存储到hbase中 部分数据: [ { "r ...

  3. METHODS OF AND APPARATUS FOR USING TEXTURES IN GRAPHICS PROCESSING SYSTEMS

    BACKGROUND The technology described herein relates to methods of and apparatus for using and handlin ...

  4. mybatis在CRUD

    一. 一个简短的引论: Mybatis本是apache的一个开源项目ibatis, 2010年这个项目由apache software foundation迁移到了google code, 而且改名为 ...

  5. 【63.63%】【codeforces 724A】Checking the Calendar

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  6. message contains no documents code:13066 mongdb数据库报的错误

    message contains no documents  code:13066stackoverflow上面的回答是: What version of the C# driver are you ...

  7. Arraylist 和 linkedlist || hashset 和treeset. || hashMap 和 TreeMap

    参考:http://liuyuan418921673.iteye.com/blog/2256120 1. ArrayList和LinkedList的区别和使用场景   ArryList 与linked ...

  8. uwp - 控件精确移动动画

    原文:uwp - 控件精确移动动画 先看效果图: 一共有8个GRID,黄色的负责移动,其他7个负责定位.新建一个页面page,替换默认代码: <UserControl.Resources> ...

  9. 1-6 WebAPI基础和演示项目搭建

    启动项目的时候 在控制台用dotnet MsgService.dll的方式启动. 在program.cs文件下做如下修改: 实现在控制台 自定义ip和端口,修改之后有将项目重新生成,在控制台启动项目, ...

  10. 一个Java工程师的入门级Linux命令集

    0.前言    网上介绍linux的命令的文章一大堆,但是大部分都是流于命令介绍,把命令的所有参数都介绍一遍,但是其实在真正的工作中,很多参数都不会用到.本文总结了我自己常用的一些命令,这些命令都比较 ...