[Android] (Yet another) fix for video launch/resume/restore
Geoffrey Métais
git at videolan.org
Tue Feb 20 13:39:41 CET 2018
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Feb 19 18:53:55 2018 +0100| [735997df4efa828860a59454d6a1b65b736902c1] | committer: Geoffrey Métais
(Yet another) fix for video launch/resume/restore
> https://code.videolan.org/videolan/vlc-android/commit/735997df4efa828860a59454d6a1b65b736902c1
---
.../src/org/videolan/vlc/gui/video/VideoPlayerActivity.java | 8 ++++----
vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt | 3 ++-
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index f4f37de55..89107ab09 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -3038,7 +3038,6 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
long savedTime = 0L;
final boolean hasMedia = mService.hasMedia();
final boolean isPlaying = mService.isPlaying();
- final boolean restorePlayback = hasMedia && mService.getCurrentMediaWrapper().getUri().equals(mUri);
/*
* If the activity has been paused by pressing the power button, then
* pressing it again will show the lock screen.
@@ -3073,10 +3072,11 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
if (intent.hasExtra(Constants.PLAY_EXTRA_ITEM_TITLE))
itemTitle = extras.getString(Constants.PLAY_EXTRA_ITEM_TITLE);
}
+ final boolean restorePlayback = hasMedia && mService.getCurrentMediaWrapper().getUri().equals(mUri);
MediaWrapper openedMedia = null;
final boolean resumePlaylist = mService.isValidIndex(positionInPlaylist);
- final boolean continueplayback = restorePlayback && isPlaying && positionInPlaylist == mService.getCurrentMediaPosition();
+ final boolean continueplayback = isPlaying && (restorePlayback || positionInPlaylist == mService.getCurrentMediaPosition());
if (resumePlaylist) {
// Provided externally from AudioService
Log.d(TAG, "Continuing playback from PlaybackService at index " + positionInPlaylist);
@@ -3092,7 +3092,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
mService.addCallback(this);
if (mUri != null) {
MediaWrapper media = null;
- if (!restorePlayback) {
+ if (!continueplayback) {
if (!resumePlaylist) {
// restore last position
media = mMedialibrary.getMedia(mUri);
@@ -3153,7 +3153,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
media.addFlags(MediaWrapper.MEDIA_VIDEO);
// Set resume point
- if (!restorePlayback) {
+ if (!continueplayback) {
if (!fromStart && savedTime <= 0L && media.getTime() > 0L)
savedTime = media.getTime();
if (savedTime > 0L)
diff --git a/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt b/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
index 3b7099a17..01453401c 100644
--- a/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
+++ b/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
@@ -284,6 +284,7 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
newMedia = true
}
} else { //Start VideoPlayer for first video, it will trigger playIndex when ready.
+ player.stop()
VideoPlayerActivity.startOpened(ctx, mw.uri, currentIndex)
}
}
@@ -304,7 +305,7 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
LocalBroadcastManager.getInstance(service).sendBroadcast(
VideoPlayerActivity.getIntent(Constants.PLAY_FROM_SERVICE,
media, false, currentIndex))
- } else if (!player.switchToVideo) {//Start the video player
+ } else if (!player.switchToVideo) { //Start the video player
VideoPlayerActivity.startOpened(VLCApplication.getAppContext(), media.uri, currentIndex)
if (!hasRenderer) player.switchToVideo = true
}
More information about the Android
mailing list