当用户几秒钟没有触摸鼠标时,我必须播放视频演示。
<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 是正确的,但它不起作用。
为什么视频无法播放,我该如何解决?