2

In my application i have a fullscreen MediaElement that reproduces a full screen video.

When i Pause the video i cannot resume it (with MediaElement1.Play()) as only audio resumes.

It seems like the video is not being redrawn properly as i tried to put a button in front of it and if i hold the button (so i guess i'm force the mediaelement in background to redraw) the video starts showing up.

This seems to be confirmed by the fact that using :

Application.Current.Host.Settings.EnableFrameRateCounter = true;

the video playback resumes properly even without the button exploit.

If anyone could help i would be very very grateful. Thanks a lot for reading and commenting.

4

2 回答 2

1

我用另一种方式解决了这个问题。我注意到在单击播放按钮两次后视频会继续播放,所以我使用 DispatcherTimer 稍后再调用一次 MyPlayer.Play()

 DispatcherTimer dt = new DispatcherTimer();

    public MainPage()
    {
        InitializeComponent();
        dt.Interval = new TimeSpan(0, 0, 0, 1);
        dt.Tick += new EventHandler(Ticked);
    }

   private void Ticked(object sender, EventArgs e)
    {
        MyPlayer.Play();
        dt.Stop();
    }
 private void Button_Click_1(object sender, RoutedEventArgs e)
    {
        MyPlayer.Play();
        dt.Start();
    }
于 2013-10-23T14:30:24.780 回答
0

我发现了一个可能的、丑陋的解决方法:

video_timer = new System.Threading.Timer(x=>refresh_video(), null, TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(1 / 60.0));

private void refresh_video()
{
    Dispatcher.BeginInvoke(delegate() { MediaElement1.InvalidateArrange(); });
}

因为它有效,我会选择这个,但我真的很喜欢更好的解决方案。

于 2013-05-13T13:17:07.957 回答