Skip to content

Commit

Permalink
v1.2.8
Browse files Browse the repository at this point in the history
 - Album Art: Extract Album art from mp3 file
  • Loading branch information
arnab-kundu committed May 11, 2024
1 parent be718c0 commit a87d8f2
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app-version.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ allprojects{
version = [
major: 1,
minor: 2,
build: 7
build: 8
]
}
}
3 changes: 3 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ dependencies {
implementation "com.google.accompanist:accompanist-pager-indicators:$accompanistPagerIndicatorsVersion"
//implementation "io.coil-kt:coil-compose:2.1.0" // to use shape drawable in compose


implementation 'com.github.wseemann:FFmpegMediaMetadataRetriever-core:1.0.19'
implementation 'com.github.wseemann:FFmpegMediaMetadataRetriever-native:1.0.19'

/** Test */
testImplementation 'junit:junit:4.13.2'
Expand Down
24 changes: 23 additions & 1 deletion app/src/main/java/com/akundu/kkplayer/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ import com.akundu.kkplayer.work.DownloadWork
import com.google.android.material.snackbar.Snackbar
import com.plcoding.manualdependencyinjection.presentation.viewModelFactory
import es.dmoral.toasty.Toasty
import wseemann.media.FFmpegMediaMetadataRetriever
import java.io.File
import java.io.FileNotFoundException

Expand Down Expand Up @@ -251,7 +252,7 @@ class MainActivity : ComponentActivity() {
verticalAlignment = Alignment.CenterVertically,
) {
Image(
painterResource(id = getDrawable(song.movie)),
bitmap = mediaMetaDataRetriever(song.fileName, song.movie),
contentDescription = null,
contentScale = ContentScale.FillBounds,
modifier = Modifier
Expand Down Expand Up @@ -497,4 +498,25 @@ class MainActivity : ComponentActivity() {
}
}

private fun mediaMetaDataRetriever(fileName: String, movie: String): ImageBitmap {
val bitmap: Bitmap
try {
val uri: String = Uri.parse(File("/storage/emulated/0/Android/media/com.akundu.kkplayer/${fileName}").toString()).toString()
val retriever: FFmpegMediaMetadataRetriever = FFmpegMediaMetadataRetriever()
retriever.setDataSource(uri)
val data: ByteArray = retriever.embeddedPicture

// convert the byte array to a bitmap
bitmap = BitmapFactory.decodeByteArray(data, 0, data.size)

// do something with the image ...
// mImageView.setImageBitmap(bitmap);
retriever.release()
return bitmap.asImageBitmap()
} catch (e: Exception) {
val icon: Bitmap = ContextCompat.getDrawable(this, getDrawable(movie))!!.toBitmap()
return icon.asImageBitmap()
}
}

}

0 comments on commit a87d8f2

Please sign in to comment.