[Android] Fix "VLC. Fix video state restoring"
Andrew Churilo
git at videolan.org
Tue Jun 14 05:31:16 UTC 2022
vlc-android | branch: master | Andrew Churilo <AndrewChuriloMinsk at gmail.com> | Mon Jun 13 12:35:37 2022 +0300| [855ece8bd738a9678b3d38981c664991fc7f6d7e] | committer: Nicolas Pomepuy
Fix "VLC. Fix video state restoring"
Fixes #2565
> https://code.videolan.org/videolan/vlc-android/commit/855ece8bd738a9678b3d38981c664991fc7f6d7e
---
.../src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
index 853689827..8e9bdd820 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
@@ -126,6 +126,7 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
lateinit var displayManager: DisplayManager
var rootView: View? = null
var videoUri: Uri? = null
+ var savedMediaList: ArrayList<MediaWrapper>? = null
private var askResume = true
var playlistModel: PlaylistModel? = null
@@ -478,6 +479,7 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
UiTools.setRotationAnimation(this)
if (savedInstanceState != null) {
savedTime = savedInstanceState.getLong(KEY_TIME)
+ savedMediaList = savedInstanceState.getParcelableArrayList(KEY_MEDIA_LIST)
val list = savedInstanceState.getBoolean(KEY_LIST, false)
if (list) {
intent.removeExtra(PLAY_EXTRA_ITEM_LOCATION)
@@ -647,6 +649,11 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
outState.putLong(KEY_TIME, savedTime)
if (playlistModel == null) outState.putParcelable(KEY_URI, videoUri)
}
+ val mediaList = service?.playlistManager?.getMediaList() ?: savedMediaList
+ if (mediaList != null) {
+ outState.putParcelableArrayList(KEY_MEDIA_LIST, ArrayList(mediaList))
+ savedMediaList = null
+ }
videoUri = null
outState.putBoolean(KEY_LIST, overlayDelegate.hasPlaylist)
}
@@ -730,6 +737,9 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
override fun onStop() {
super.onStop()
+ service?.playlistManager?.getMediaList()?.let {
+ savedMediaList = ArrayList(it)
+ }
startedScope.cancel()
LocalBroadcastManager.getInstance(this).unregisterReceiver(serviceReceiver)
@@ -2154,6 +2164,10 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
open fun onServiceChanged(service: PlaybackService?) {
if (service != null) {
this.service = service
+ if (savedMediaList != null && service.currentMediaWrapper == null) {
+ service.append(savedMediaList!!)
+ savedMediaList = null
+ }
//We may not have the permission to access files
if (!switchingView)
handler.sendEmptyMessage(START_PLAYBACK)
@@ -2202,6 +2216,7 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
internal const val DEFAULT_FOV = 80f
private const val KEY_TIME = "saved_time"
private const val KEY_LIST = "saved_list"
+ private const val KEY_MEDIA_LIST = "media_list"
private const val KEY_URI = "saved_uri"
const val OVERLAY_INFINITE = -1
const val FADE_OUT = 1
More information about the Android
mailing list