Commit 870ec8ae authored by Geoffrey Métais's avatar Geoffrey Métais

TV Channels: Wait for thumbnail

parent 1f245e48
......@@ -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()
......
......@@ -91,9 +91,10 @@ fun Context.launchChannelUpdate() = AppScope.launch {
updatePrograms(this@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@artUri, 512) }
}
val mrl = artworkMrl ?: return Uri.parse("android.resource://${BuildConfig.APPLICATION_ID}/${R.drawable.ic_browser_video_big_normal}")
return try {
getFileUri(mrl)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment