使用 C1MediaPlayer 播放视频

发布时间:2013/10/22 00:10 发布者:iceman

返回博客中心

ComponnetOne Silverlight 和 WPF 平台提供了视频播放控件 C1MediaPlayer。可以在应用中添加视频播放功能,增强应用的可交互性。本篇文章是一篇基础应用文章-将阐述如何使用 C1MediaPlayer 播放视频文件。对于刚刚接触ComponnentOne控件套包的用户将有所帮助。下面分步讲解使用方法:

1.在 XMAL 页面添加 C1MediaPlayer 控件。

  1:  <c1:C1MediaPlayer  Height="800" VerticalAlignment="Top" Name="c1mediaplayer"/>

 

2.添加 Button 并且调用 Click 事件调用 OpenFileDialog 选择文件:

  1: <Button Width="70" Height="20" Content="选择文件" VerticalAlignment="Bottom" Click="Button_Click"/>

 

3.Button Click 事件中选择文件代码如下:

  1:         private void Button_Click(object sender, RoutedEventArgs e)
  2:         {
  3:             OpenFileDialog op = new OpenFileDialog()
  4:             {
  5:                 Filter = "Video files(*.wmv)|*.wmv|All Files(*.*)|*.*"
  6:             };
  7:             
  8:             if (op.ShowDialog()==true)
  9:             {
 10:                 //读取视频文件流
 11:                 FileStream stream = op.File.OpenRead();
 12: 
 13:                 //添加视频项
 14:                 C1MediaItem plI = new C1MediaItem();
 15:                 plI.MediaStream = stream;
 16:                 c1mediaplayer.Items.Add(plI);
 17: 
 18:                 //自动播放视频
 19:                 c1mediaplayer.Play();
 20:             }
 21:         }

 

效果图:

 

Demo1

 

最后给出 C1MediaPlayer 支持的文件格式:

支持如下视频格式:

•Raw Video
•YV12 - YCrCb(4:2:0)
•RGBA - 32 bit Alpha Red, Green, Blue
•WMV, MV2, and MV3 ( Windows Media Video 7, 8, and 9)
•Supports Simple and Main Profiles
•Supports only progressive (non-interlaced) content.
•WMVA: Windows Media Video Advanced Profile, non-VC-1.
•WVC1: Windows Media Video Advanced Profile, VC-1.
•Supports Advanced Profile.
•Supports only progressive (non-interlaced) content.
•H264 (ITU-T H.264 / ISO MPEG-4 AVC).

支持如下音频格式:
•“1” - WAV format.
•"353" - Microsoft Windows Media Audio v7, v8 and v9.x Standard (WMA Standard).
•"354" - Microsoft Windows Media Audio v9.x and v10 Professional (WMA Professional).
•"85" - ISO MPEG-1 Layer III (MP3).
•"255" - ISO Advanced Audio Coding (AAC).

 

 

Demo 下载:vs2010 + silverlight 5.0 + Studio for Silverlight 2013V2.5 + C#


关于葡萄城

赋能开发者!葡萄城是专业的集开发工具、商业智能解决方案、低代码开发平台于一身的软件和服务提供商,为超过 75% 的全球财富 500 强企业提供服务。葡萄城专注控件软件领域30年,希望通过模块化的开发控件、灵活的低代码应用开发平台等一系列开发工具、解决方案和服务,帮助开发者快速响应复杂多变的业务需求,最大程度地发挥开发者的才智和潜能,让开发者的 IT 人生更从容更美好。

了解详情,请访问葡萄城官网