[Android] TV Channels: Wait for thumbnail
Geoffrey Métais
git at videolan.org
Thu May 16 17:17:41 CEST 2019
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu May 16 14:31:01 2019 +0200| [870ec8ae5ecac9077cc3edb490d330f86ad34337] | committer: Geoffrey Métais
TV Channels: Wait for thumbnail
> https://code.videolan.org/videolan/vlc-android/commit/870ec8ae5ecac9077cc3edb490d330f86ad34337
---
vlc-android/src/org/videolan/vlc/util/ThumbnailsProvider.kt | 5 ++---
vlc-android/src/org/videolan/vlc/util/TvChannels.kt | 8 ++++++--
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/util/ThumbnailsProvider.kt b/vlc-android/src/org/videolan/vlc/util/ThumbnailsProvider.kt
index ff582d860..8d4e4940b 100644
--- a/vlc-android/src/org/videolan/vlc/util/ThumbnailsProvider.kt
+++ b/vlc-android/src/org/videolan/vlc/util/ThumbnailsProvider.kt
@@ -17,7 +17,6 @@ import org.videolan.medialibrary.media.Folder
import org.videolan.medialibrary.media.MediaLibraryItem
import org.videolan.medialibrary.media.MediaWrapper
import org.videolan.vlc.VLCApplication
-import org.videolan.vlc.gui.helpers.AudioUtil
import org.videolan.vlc.gui.helpers.AudioUtil.readCoverBitmap
import org.videolan.vlc.gui.helpers.BitmapCache
import org.videolan.vlc.gui.helpers.BitmapUtil
@@ -50,7 +49,7 @@ object ThumbnailsProvider {
return if (item.type == MediaWrapper.TYPE_VIDEO && TextUtils.isEmpty(item.artworkMrl))
getVideoThumbnail(item, width)
else
- AudioUtil.readCoverBitmap(Uri.decode(item.artworkMrl), width)
+ readCoverBitmap(Uri.decode(item.artworkMrl), width)
}
fun getMediaCacheKey(isMedia: Boolean, item: MediaLibraryItem): String? {
@@ -64,7 +63,7 @@ object ThumbnailsProvider {
}
@WorkerThread
- private fun getVideoThumbnail(media: MediaWrapper, width: Int): Bitmap? {
+ fun getVideoThumbnail(media: MediaWrapper, width: Int): Bitmap? {
val filePath = media.uri.path
if (appDir == null) appDir = VLCApplication.appContext.getExternalFilesDir(null)
val hasCache = appDir != null && appDir!!.exists()
diff --git a/vlc-android/src/org/videolan/vlc/util/TvChannels.kt b/vlc-android/src/org/videolan/vlc/util/TvChannels.kt
index 6219cb13b..a3b1b0839 100644
--- a/vlc-android/src/org/videolan/vlc/util/TvChannels.kt
+++ b/vlc-android/src/org/videolan/vlc/util/TvChannels.kt
@@ -91,9 +91,10 @@ fun Context.launchChannelUpdate() = AppScope.launch {
updatePrograms(this at launchChannelUpdate, id)
}
-fun setResumeProgram(context: Context, mw: MediaWrapper) {
+suspend fun setResumeProgram(context: Context, mw: MediaWrapper) {
var cursor: Cursor? = null
var isProgramPresent = false
+ val mw = context.getFromMl { findMedia(mw) }
try {
cursor = context.contentResolver.query(
TvContractCompat.WatchNextPrograms.CONTENT_URI, WATCH_NEXT_MAP_PROJECTION, null,
@@ -132,7 +133,10 @@ fun setResumeProgram(context: Context, mw: MediaWrapper) {
}
-private fun MediaWrapper.artUri() : Uri {
+private suspend fun MediaWrapper.artUri() : Uri {
+ if (!isThumbnailGenerated) {
+ withContext(Dispatchers.IO) { ThumbnailsProvider.getVideoThumbnail(this at artUri, 512) }
+ }
val mrl = artworkMrl ?: return Uri.parse("android.resource://${BuildConfig.APPLICATION_ID}/${R.drawable.ic_browser_video_big_normal}")
return try {
getFileUri(mrl)
More information about the Android
mailing list