【问题标题】:C# playing a video fileC# 播放视频文件
【发布时间】:2013-11-07 00:48:39
【问题描述】:
this.Background = new System.Windows.Media.ImageBrush(new System.Windows.Media.Imaging.BitmapImage(new Uri(MY URL HERE)));

上面的代码帮助我显示一个图像控件及其图像。 我想播放视频文件。

System.Windows.Media库有没有办法播放视频文件?

【问题讨论】:

    标签: c# video shared-libraries media-player


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

      如果你使用的是 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

      【讨论】:

      • 创建一个绘图笔刷并将背景设置为绘图笔刷。我编辑了这个例子。我试过了,效果很好。如果出现黑屏,则 Uri 可能是错误的。如果成功了就让我来
      猜你喜欢
      • 2013-07-21
      • 2020-03-26
      • 1970-01-01
      • 1970-01-01
      • 2018-12-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多