我必须播放视频演示时,用户不触摸鼠标几秒钟。播放视频黑色矩形
<Window x:Class="IHM.Animation"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" ResizeMode="NoResize" WindowState="Maximized" WindowStyle="None" WindowStartupLocation="CenterScreen" >
<Grid>
<MediaElement HorizontalAlignment="Left" Name="video" Height="221" Margin="160,255,0,0" VerticalAlignment="Top" Width="436" />
</Grid>
</Window>
对于CSHARP类,我有这样的:
public partial class Animation : Window
{
public Animation()
{
InitializeComponent();
MediaPlayer player = new MediaPlayer();
player.Open(new Uri(@"airplane.mpg", UriKind.Relative));
VideoDrawing drawing = new VideoDrawing {Rect = new Rect(0, 0, System.Windows.SystemParameters.PrimaryScreenHeight, System.Windows.SystemParameters.PrimaryScreenWidth)};
player.Play();
DrawingBrush brush = new DrawingBrush(drawing);
Background = brush;
MouseMove += (sender, args) =>
{
player.Stop();
Close();
};
player.MediaEnded += (sender, args) => Close();
}
}
但是,我有没有视频的儿子或形象。URI一个黑色矩形是正确的,但它不工作。
为什么视频无法正常工作,我该如何解决它?
你可以在Windows Media Player中播放视频吗?它工作吗? – 2013-05-13 14:30:36
看到我的更新代码 – 2013-05-13 14:38:16
首先,注释掉MouseMove处理程序,看看它是否工作。 – Dusan 2013-05-13 15:19:30