Commit fc17aab3 authored by Martin Finkel's avatar Martin Finkel

Use OnPause instead of OnStop, pause mediaplayer to retrieve more precise...

Use OnPause instead of OnStop, pause mediaplayer to retrieve more precise position and reset position when back to foreground
parent 8638f2b5
......@@ -21,11 +21,12 @@ namespace ForegroundBackground.Droid
LoadApplication(new App());
}
protected override void OnStop()
protected override void OnPause()
{
base.OnStop();
base.OnPause();
MessagingCenter.Send("app", "OnPause");
MessagingCenter.Send("app", "OnStop");
}
protected override void OnRestart()
......
......@@ -16,9 +16,10 @@ namespace ForegroundBackground
{
InitializeComponent();
MessagingCenter.Subscribe<string>(this, "OnStop", app =>
MessagingCenter.Subscribe<string>(this, "OnPause", app =>
{
VideoView.Loaded -= VideoView_Loaded;
_mediaPlayer.Pause();
_position = _mediaPlayer.Position;
_mediaPlayer.Stop();
MainGrid.Children.Clear();
......@@ -34,6 +35,7 @@ namespace ForegroundBackground
_videoView.MediaPlayer = _mediaPlayer;
_videoView.MediaPlayer.Position = _position;
_position = 0;
});
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment