The video player should switch to audio only if it is not the system pip
(if not pressing the cross to kill it, will keep audio running) or if
the screen is off.
The previous condition stopped the player from switching to audio when
playback in background was enabled
Regression introduced in 95bb1f3a5bFixes#3200
By getting a media from the medialibrary from the the currentmedia's uri
to ensure that we have the medialibrary metadata for the file, the new
media from the same uri won't have the flags previously set, including
MEDIA_FORCE_AUDIO which start the media as audio.
To fix this, the flags from the previous mediawrapper are applied to the
new one.
Fixed a regression introduced by ea39df7bb7
In onSaveInstanceState, without a currentMediaList we would default to
savedMediaList, but without a currentIndex, we would default to 0 and
not to savedMediaIndex.
When restarting the videoplayer, we do have a savedInstanceState in the
on create that is used to reload the previous medialist, but it only
reloaded 0.
startTime in playIndex should default to the time saved in the
medialibrary and not savedTime. savedTime is mostly used to resume when
we don't saveMediaMeta, and will be less precise than the medialibrary
saved time.
When you open pip with play in background, when you quit pip, in the
onStop, it will switch to audio. If you check if system Pip is running
you can stop that, but it will stop playback from running with the screen off,
so check for screen off also.
This means that isInPiPMode will stay true,
even though PiP has been killed a while ago, audio playback in
background is still running.