[Android] TV Channels: Wait for thumbnail

Geoffrey Métais git at videolan.org
Thu May 16 16:55:10 CEST 2019


vlc-android | branch: 3.1.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu May 16 14:31:01 2019 +0200| [8f45335b8eb937e8acf932386f19c0ea3c1137f0] | committer: Geoffrey Métais

TV Channels: Wait for thumbnail

> https://code.videolan.org/videolan/vlc-android/commit/8f45335b8eb937e8acf932386f19c0ea3c1137f0
---

 vlc-android/src/org/videolan/vlc/util/ThumbnailsProvider.java | 2 +-
 vlc-android/src/org/videolan/vlc/util/TvChannels.kt           | 8 ++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/util/ThumbnailsProvider.java b/vlc-android/src/org/videolan/vlc/util/ThumbnailsProvider.java
index 600ecc75d..7201d6b16 100644
--- a/vlc-android/src/org/videolan/vlc/util/ThumbnailsProvider.java
+++ b/vlc-android/src/org/videolan/vlc/util/ThumbnailsProvider.java
@@ -63,7 +63,7 @@ public class ThumbnailsProvider {
     }
 
     @WorkerThread
-    private static Bitmap getVideoThumbnail(final MediaWrapper media, int width) {
+    static Bitmap getVideoThumbnail(final MediaWrapper media, int width) {
         final String filePath = media.getUri().getPath();
         if (appDir == null) appDir = VLCApplication.getAppContext().getExternalFilesDir(null);
         final boolean 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