[Android] Fix stream media type lost
Geoffrey Métais
git at videolan.org
Mon Jul 30 12:02:45 CEST 2018
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Jul 30 12:00:33 2018 +0200| [c4eb6826dd608932188cced660938d87053e2fa2] | committer: Geoffrey Métais
Fix stream media type lost
> https://code.videolan.org/videolan/vlc-android/commit/c4eb6826dd608932188cced660938d87053e2fa2
---
.../src/org/videolan/vlc/media/MediaWrapperList.java | 5 ++++-
.../src/org/videolan/vlc/media/PlaylistManager.kt | 17 +++++++++++++----
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/media/MediaWrapperList.java b/vlc-android/src/org/videolan/vlc/media/MediaWrapperList.java
index 40c05d5b4..d45a44da9 100644
--- a/vlc-android/src/org/videolan/vlc/media/MediaWrapperList.java
+++ b/vlc-android/src/org/videolan/vlc/media/MediaWrapperList.java
@@ -179,7 +179,10 @@ public class MediaWrapperList {
final MediaWrapper media = iter.next();
if (media.getId() == 0L) {
final MediaWrapper mw = ml.findMedia(media);
- if (mw.getId() != 0) iter.set(mw);
+ if (mw.getId() != 0) {
+ if (mw.getType() == MediaWrapper.TYPE_ALL) mw.setType(media.getType());
+ iter.set(mw);
+ }
}
}
}
diff --git a/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt b/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
index 3cb874aa8..96eeab756 100644
--- a/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
+++ b/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
@@ -300,7 +300,7 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
if (internalMedia != null && internalMedia.id != 0L)
id = internalMedia.id
else {
- internalMedia = medialibrary.addMedia(Uri.decode(mw.uri.toString()))
+ internalMedia = if (mw.type == MediaWrapper.TYPE_STREAM) medialibrary.addStream(Uri.decode(mw.uri.toString()), mw.title) else medialibrary.addMedia(Uri.decode(mw.uri.toString()))
if (internalMedia != null)
id = internalMedia.id
}
@@ -536,6 +536,7 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
@MainThread
private suspend fun expand(updateHistory: Boolean): Int {
val index = currentIndex
+ val stream = getCurrentMedia()?.type == MediaWrapper.TYPE_STREAM
val ml = player.expand()
var ret = -1
@@ -548,7 +549,12 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
mediaList.insert(index, MediaWrapper(child))
child.release()
}
- if (mrl !== null && ml.count == 1) medialibrary.addToHistory(mrl, getCurrentMedia()!!.title)
+ if (mrl !== null && ml.count == 1) {
+ if (stream) {
+ getCurrentMedia()!!.type = MediaWrapper.TYPE_STREAM
+ medialibrary.addStream(mrl, getCurrentMedia()!!.title)
+ } else medialibrary.addToHistory(mrl, getCurrentMedia()!!.title)
+ }
ret = index
}
ml?.release()
@@ -662,7 +668,10 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
MediaPlayer.Event.Playing -> {
medialibrary.pauseBackgroundOperations()
videoBackground = false
- val mw = withContext(VLCIO) { medialibrary.findMedia(getCurrentMedia()) }
+ val mw = withContext(VLCIO) {
+ val current = getCurrentMedia()
+ medialibrary.findMedia(current).apply { if (type == -1) type = current?.type ?: -1 }
+ }
if (newMedia) {
loadMediaMeta(mw)
if (mw.type == MediaWrapper.TYPE_STREAM) medialibrary.addToHistory(mw.location, mw.title)
@@ -689,7 +698,7 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
MediaPlayer.Event.EncounteredError -> {
service.showToast(service.getString(
R.string.invalid_location,
- getCurrentMedia()?.getLocation() ?: ""), Toast.LENGTH_SHORT)
+ getCurrentMedia()?.location ?: ""), Toast.LENGTH_SHORT)
if (currentIndex != nextIndex) next() else stop()
}
}
More information about the Android
mailing list