繁体   English   中英

C#播放视频文件

[英]C# playing a video file

this.Background = new System.Windows.Media.ImageBrush(new System.Windows.Media.Imaging.BitmapImage(new Uri(MY URL HERE)));

上面的代码可以帮助我显示图像控件及其图像。 我要播放视频文件。

System.Windows.Media库是否具有播放视频文件的任何方法?

如果您使用的是WPF,则可以尝试以下操作:

// 
// Create a VideoDrawing. 
//      
MediaPlayer player = new MediaPlayer();

player.Open(new Uri(@"sampleMedia\xbox.wmv", UriKind.Relative));

VideoDrawing aVideoDrawing = new VideoDrawing();

aVideoDrawing.Rect = new Rect(0, 0, 100, 100);

aVideoDrawing.Player = player;

DrawingBrush brush = new DrawingBrush(aVideoDrawing);
this.Background = brush;

// Play the video once.
player.Play();    

来源: http//msdn.microsoft.com/en-us/library/aa969812.aspx

看看这个: Videobrush 让我知道这是否适合您。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM