This project is read-only.

Tombstoning app WP8, keep seek position

Topics: Windows Phone 8
Jan 22, 2014 at 1:26 PM
Edited Jan 22, 2014 at 1:26 PM
Tombstoning an app while a video is loaded in the player framework mediaplayer is not totally working correctly when a video is paused.

Before tombstoning:

After returning on the page:

As you can see the state of the mediaplayer is saved (it is not grayed out) with the sample code given over here:

But if a user pauses the video and tombstones the app, the seek position is gone and the player is black with an indeterminate progressbar crossing it when returning to the app. When pressing the play button the video plays from the beginning.

How do I get rid of the indeterminate progressbar, and how can I store the seek position (and current pause image) before tombstoning the app?
Jan 22, 2014 at 2:17 PM
I sort of fixed it by including these pieces of code, but of course this user case should be included in the mediaplayer.GetMediaState() and mediaplayer.RestoreMediaState() functions
        private bool resumed = false;
        private TimeSpan playerposition;

         private void mediaPlayer_MediaOpened(object sender, RoutedEventArgs e)
                if (resumed)
                    resumed = false;
                    mediaPlayer.Position = playerposition;

        void Current_Activated(object sender, ActivatedEventArgs e)
            if (deactivatedState != null)
                resumed = true;

        void Current_Deactivated(object sender, DeactivatedEventArgs e)
            mediaPlayer.Close(); // shut things like ads down.
            deactivatedState = playerState;
            playerposition = mediaPlayer.VirtualPosition;

Marked as answer by sverrevh on 1/22/2014 at 6:33 AM