[Android] Fix new video not loading when already in PiP
Nicolas Pomepuy
git at videolan.org
Wed Apr 6 14:06:12 UTC 2022
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Apr 5 11:40:40 2022 +0200| [da029ee76123e393f8e57f911fb8b44fb4ff9be2] | committer: Duncan McNamara
Fix new video not loading when already in PiP
Fixes #2421
> https://code.videolan.org/videolan/vlc-android/commit/da029ee76123e393f8e57f911fb8b44fb4ff9be2
---
.../org/videolan/vlc/gui/video/VideoPlayerActivity.kt | 17 +++++++----------
.../videolan/vlc/gui/video/benchmark/BenchActivity.kt | 4 ++--
2 files changed, 9 insertions(+), 12 deletions(-)
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 5ac014957..33844278a 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
@@ -595,6 +595,7 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
lastTime = -1
forcedTime = lastTime
enableSubs()
+ if (this.isPlaying) loadMedia(forceUsingNew = true)
}
}
@@ -1779,14 +1780,6 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
rootView?.run { keepScreenOn = false }
}
- /*
- * Additionnal method to prevent alert dialog to pop up
- */
- private fun loadMedia(fromStart: Boolean) {
- askResume = false
- intent.putExtra(PLAY_EXTRA_FROM_START, fromStart)
- loadMedia()
- }
/**
* External extras:
@@ -1797,7 +1790,11 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
*/
@SuppressLint("SdCardPath")
@TargetApi(12)
- protected open fun loadMedia() {
+ protected open fun loadMedia(fromStart: Boolean = false, forceUsingNew:Boolean = false) {
+ if (fromStart) {
+ askResume = false
+ intent.putExtra(PLAY_EXTRA_FROM_START, fromStart)
+ }
service?.let { service ->
isPlaying = false
var title: String? = null
@@ -1898,7 +1895,7 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
// Start playback & seek
/* prepare playback */
val medialoaded = media != null
- if (!medialoaded) media = if (hasMedia) currentMedia else MLServiceLocator.getAbstractMediaWrapper(uri)
+ if (!medialoaded) media = if (hasMedia && !forceUsingNew) currentMedia else MLServiceLocator.getAbstractMediaWrapper(uri)
itemTitle?.let { media?.title = Uri.decode(it) }
if (wasPaused) media?.addFlags(MediaWrapper.MEDIA_PAUSED)
if (intent.hasExtra(PLAY_DISABLE_HARDWARE)) media?.addFlags(MediaWrapper.MEDIA_NO_HWACCEL)
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/benchmark/BenchActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/benchmark/BenchActivity.kt
index 602e0db15..a62c920d3 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/video/benchmark/BenchActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/video/benchmark/BenchActivity.kt
@@ -147,10 +147,10 @@ class BenchActivity : ShallowVideoPlayer() {
}
}
- override fun loadMedia() {
+ override fun loadMedia(fromStart: Boolean, forceUsingNew: Boolean) {
service?.setBenchmark()
if (isHardware) service?.setHardware()
- super.loadMedia()
+ super.loadMedia(fromStart, true)
}
override fun onCreate(savedInstanceState: Bundle?) {
More information about the Android
mailing list