各位大侠,我有这样一个需求:实现一个函数,它能够在一个Grid上添加一个Mediaplayer、打开视频文件并直接把画面定格在某一时间点。
我是这样写的:
private void show_video(Grid parent, string filename, TimeSpan time, int width, int height)
{
ExpressionMediaPlayer.MediaPlayer media_player = new ExpressionMediaPlayer.MediaPlayer();
media_player.Height = height;
media_player.Width = width;
ExpressionMediaPlayer.PlaylistItem pli = new ExpressionMediaPlayer.PlaylistItem();
pli.MediaSource = new Uri(filename);
ExpressionMediaPlayer.ChapterItem chapter = new ExpressionMediaPlayer.ChapterItem();
chapter.Position = 9;
pli.Chapters.Add(chapter);
media_player.Playlist.Items.Add(pli);
parent.Children.Add(media_player);
media_player.StateChanged += new RoutedEventHandler(media_player_StateChanged);
my_time = time;
seek_time(time);//如何实现定位时间的功能?
}
到 seek_time(time)之前为止,添加mediaplayer并打开视频文件是没问题的,但是之后定位时间该如何操作呢?