inthehand / InTheHand.Forms

Extras for Xamarin Forms including MediaElement

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Video Won't Restart

jonathan-austen opened this issue · comments

When I do a PopToRootAsync() and load up the main page which is using your video control, the video is stopped. The Media.CurrentState says it's Playing but it's not. It's frozen.

I've been able to narrow it down to that when the application I wrote opens the camera to take a picture and returns to the app, the video then freezes. Any idea why?

Do you have any code to pause/stop the video when the page is navigated away from?

Oh and if I say Movie.Play() even when the STATE says it's stopped, it won't play.

I think I got it and want to share with your users. In the code below, I added the first line, which adds a new copy of my MainPage. That is where my video is looping. By doing that, it puts a 2nd one in the stack, then I clear the stack to the root and the program returns to the main page and the video plays as expected. I'm sure this isn't ideal, but it works and the end result does not have any extra windows open taking up memory.

    public static void ClearNavigationStack(INavigation navigation)
    {
        navigation.InsertPageBefore(new MainPage(), navigation.NavigationStack[0]);
        navigation.PopToRootAsync();           
    }