Skip to content

Snappy1

  • Home
  • Android
  • What
  • How
  • Is
  • Can
  • Does
  • Do
  • Why
  • Are
  • Who
  • Toggle search form

[FIXED] java – How to Create a Thumbnail of mp3 file

Posted on November 11, 2022 By

Solution 1 :

I would check which version of Android you are targeting in your project.

That override for createAudioThumbnail() was added in API v29. Check here for the documentation.

If you are targeting a lower API version you might need to do something like this:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
    ThumbnailUtils.createAudioThumbnail(file, Size(THUMBSIZE, THUMBSIZE), null)
} else {
    // Use the deprecated version for older devices.
    ThumbnailUtils.createAudioThumbnail(filepath, MediaStore.Images.Thumbnails.MINI_KIND)
}

Problem :

Hey Recently I am working on Music Player project and I have cover mostly things but I am Stucked how to create the mp3 files thumbnails.I have tried this

  final int THUMBSIZE = 64 ;
  File file= new File(songpathll);
  Bitmap bitmap = ThumbnailUtils.createAudioThumbnail(file, new Size(100,100),null);

this is showing error

  java.lang.NoSuchMethodError: No static method createAudioThumbnail(Ljava/io/File;Landroid/util/Size;Landroid/os/CancellationSignal;)Landroid/graphics/Bitmap; in class Landroid/media/ThumbnailUtils; or its super classes (declaration of 'android.media.ThumbnailUtils' appears in /system/framework/framework.jar)

Comments

Comment posted by createAudioThumbnail

createAudioThumbnail

Comment posted by DikShU

28 That’s fine .

Comment posted by Joachim Sauer

What do you mean by “that’s fine”? You can’t use API 29 methods if your target SDK level is 28.

Comment posted by DikShU

i also tried the method below api level 29 thats also giving same error

Comment posted by developer.android.com/reference/android/media/…

If you are trying to add artwork to an MP3 file, we might be better off looking at

Comment posted by DikShU

I have set my minimum sdk version to 22 so that no error occurs and my target level is 28 .thats usually fine.

Comment posted by developer.android.com/reference/android/media/…

OK, so it looks like for your use case you can use this version of createAudioThumbnail:

Comment posted by Joachim Sauer

According to the docs,

READ  [FIXED] java - Load Imageview in ViewHolder
Powered by Inline Related Posts

Comment posted by bcpettifer

Well that is intriguing. I’m wondering if the most suitable thing then is to just use the

Comment posted by DikShU

i will try ThumbnailUtils.extractThumbnail and update you if it Works

Android Tags:android, java, kotlin, thumbnails

Post navigation

Previous Post: [FIXED] Problem with the implementation of the Android Studio Java design libraries
Next Post: [FIXED] android – Kotlin: Typeconverter for other class type

Related Posts

[FIXED] kotlin – android box shadow troubles Android
[FIXED] why splash screen in android doesn’t fit inside the available space? Android
[FIXED] android – AutoCompleteView sending data to RecycleView Android
[FIXED] android – How to dynamically load apps like Expo client Android
[FIXED] java – How to add Buttons and other stuff like Image Viiew in default Bottom Tab Activity of Android Android
[FIXED] Different encryption Android vs pure Java – RSA/ECB/OAEPWithMD5AndMGF1Padding Android

Archives

  • April 2023
  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuándo
  • ¿Cuántas
  • ¿Cuánto
  • ¿Qué
  • Android
  • Are
  • At
  • C'est
  • Can
  • Comment
  • Did
  • Do
  • Does
  • Est-ce
  • Est-il
  • For
  • Has
  • Hat
  • How
  • In
  • Is
  • Ist
  • Kann
  • Où
  • Pourquoi
  • Quand
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welchen
  • Welcher
  • Welches
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Who's
  • Why
  • Wie
  • Will
  • Wird
  • Wo
  • Woher
  • you can create a selvedge edge: You can make the edges of garter stitch more smooth by slipping the first stitch of every row.2022-02-04
  • you really only need to know two patterns: garter stitch

Recent Posts

  • Can Vicks humidifier be used without filter?
  • What color is Spanish green?
  • How old is Jamie in The War That Saved My Life?
  • When should I use scalp massager for hair growth?
  • Can I put polyurethane over liming wax?

Recent Comments

No comments to show.

Copyright © 2023 Snappy1.

Powered by PressBook Grid Dark theme