Browse Source

Fix "opened_position" intent extra, to use for index based playlist opening

merge-requests/1666/merge
popy popy 3 years ago
committed by Duncan McNamara
parent
commit
8880ccca3b
  1. 2
      application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
  2. 2
      application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
  3. 19
      application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt

2
application/vlc-android/src/org/videolan/vlc/PlaybackService.kt

@ -1438,7 +1438,7 @@ class PlaybackService : MediaBrowserServiceCompat(), LifecycleOwner, CoroutineSc
} }
@MainThread @MainThread
fun load(media: MediaWrapper) = load(listOf(media), 0) fun load(media: MediaWrapper, position: Int = 0) = load(listOf(media), position)
/** /**
* Play a media from the media list (playlist) * Play a media from the media list (playlist)

2
application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt

@ -2035,7 +2035,7 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
if (displayManager.isPrimary) service.flush() if (displayManager.isPrimary) service.flush()
onPlaying() onPlaying()
} else service.playIndex(positionInPlaylist) } else service.playIndex(positionInPlaylist)
} else service.load(media) } else service.load(media, positionInPlaylist)
// Get the title // Get the title
if (itemTitle == null && "content" != uri.scheme) title = uri.lastPathSegment if (itemTitle == null && "content" != uri.scheme) title = uri.lastPathSegment

19
application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt

@ -57,6 +57,7 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
var currentIndex = -1 var currentIndex = -1
private var nextIndex = -1 private var nextIndex = -1
private var prevIndex = -1 private var prevIndex = -1
var startupIndex = -1
private var previous = Stack<Int>() private var previous = Stack<Int>()
var stopAfter = -1 var stopAfter = -1
var repeating = PlaybackStateCompat.REPEAT_MODE_NONE var repeating = PlaybackStateCompat.REPEAT_MODE_NONE
@ -169,7 +170,12 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
Log.w(TAG, "Warning: empty media list, nothing to play !") Log.w(TAG, "Warning: empty media list, nothing to play !")
return return
} }
currentIndex = if (isValidPosition(position)) position else 0 if (isValidPosition(position)) {
currentIndex = position
} else {
currentIndex = 0
startupIndex = if(position >= 0) position else 0
}
// Add handler after loading the list // Add handler after loading the list
mediaList.addEventListener(this@PlaylistManager) mediaList.addEventListener(this@PlaylistManager)
@ -268,7 +274,14 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
val size = mediaList.size() val size = mediaList.size()
if (force || repeating != PlaybackStateCompat.REPEAT_MODE_ONE) { if (force || repeating != PlaybackStateCompat.REPEAT_MODE_ONE) {
previous.push(currentIndex) previous.push(currentIndex)
currentIndex = nextIndex //startup index given?
if (startupIndex != -1) {
currentIndex = startupIndex
startupIndex = -1
} else {
//no startup index given, use next
currentIndex = nextIndex
}
if (size == 0 || currentIndex < 0 || currentIndex >= size) { if (size == 0 || currentIndex < 0 || currentIndex >= size) {
Log.w(TAG, "Warning: invalid next index, aborted !") Log.w(TAG, "Warning: invalid next index, aborted !")
stop() stop()
@ -1123,4 +1136,4 @@ class DelayValues(var start: Long = -1L, var stop: Long = -1L)
class WaitConfirmation(val title: String, val index: Int, val flags: Int) class WaitConfirmation(val title: String, val index: Int, val flags: Int)
enum class VideoResumeStatus { enum class VideoResumeStatus {
ALWAYS, ASK, NEVER ALWAYS, ASK, NEVER
} }

Loading…
Cancel
Save