Question

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.

Was it helpful?

Solution

I solved this problem in another way. I noticed that video resumes after clicking Play button twice, so I used DispatcherTimer to call MyPlayer.Play() for one more time a moment later

 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();
    }

OTHER TIPS

I found a possible, ugly, workaround:

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(); });
}

Since it works i will go with this but i'd really love a better solution.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top