music: use aosp covers by default
Less good, but it's also far more memory efficient.
This commit is contained in:
parent
f57ee549f1
commit
3dbe06c0bc
3 changed files with 10 additions and 5 deletions
|
@ -18,19 +18,22 @@
|
|||
|
||||
package org.oxycblt.auxio.image.stack.extractor
|
||||
|
||||
import android.content.Context
|
||||
import android.media.MediaMetadataRetriever
|
||||
import android.net.Uri
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import java.io.InputStream
|
||||
import javax.inject.Inject
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
class AOSPCoverSource @Inject constructor() : CoverSource {
|
||||
class AOSPCoverSource @Inject constructor(@ApplicationContext private val context: Context) :
|
||||
CoverSource {
|
||||
override suspend fun extract(fileUri: Uri): InputStream? {
|
||||
val mediaMetadataRetriever = MediaMetadataRetriever()
|
||||
val cover =
|
||||
withContext(Dispatchers.IO) {
|
||||
mediaMetadataRetriever.setDataSource(fileUri.toString())
|
||||
mediaMetadataRetriever.setDataSource(context, fileUri)
|
||||
mediaMetadataRetriever.embeddedPicture
|
||||
} ?: return null
|
||||
return cover.inputStream()
|
||||
|
|
|
@ -35,5 +35,5 @@ interface ExtractorModule {
|
|||
class CoverSourcesModule {
|
||||
@Provides
|
||||
fun coverSources(exoPlayerCoverSource: ExoPlayerCoverSource, aospCoverSource: AOSPCoverSource) =
|
||||
CoverSources(listOf(exoPlayerCoverSource, aospCoverSource))
|
||||
CoverSources(listOf(aospCoverSource, exoPlayerCoverSource))
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ class AlbumImpl(linkedAlbum: LinkedAlbum) : Album {
|
|||
override val releaseType = preAlbum.releaseType
|
||||
override var durationMs = 0L
|
||||
override var dateAdded = 0L
|
||||
override var cover = Cover.nil()
|
||||
override var cover: Cover = Cover.nil()
|
||||
override var dates: Date.Range? = null
|
||||
|
||||
override val artists = linkedAlbum.artists.resolve(this)
|
||||
|
@ -123,7 +123,9 @@ class AlbumImpl(linkedAlbum: LinkedAlbum) : Album {
|
|||
}
|
||||
}
|
||||
|
||||
fun finalize() {}
|
||||
fun finalize() {
|
||||
cover = Cover.single(Sort(Sort.Mode.ByTrack, Sort.Direction.ASCENDING).songs(songs).first())
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue