Glide fails to load resources when trying to load an audio file from smartphone

  • Respostas:0
  • AbertoNão stickySem resposta
  • Posts no fórum: 8

28/01/2020, 13:58:09 via Web

Problems
Messages in Logcat I'm getting from Android Studio:

01-16 11:27:34.088 15846-15846/? W/Glide: Load failed for /storage/emulated/0/9fe457b5-7baf-459d-be34-76ec5c2bcf74audio_record.3gp with size [80x80] 
class com.bumptech.glide.load.engine.GlideException: Failed to load resource
     Cause (1 of 3): class com.bumptech.glide.load.engine.GlideException: Failed LoadPath{FileInputStream->Object->Drawable}, LOCAL
       Cause (1 of 3): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{FileInputStream->GifDrawable->Drawable}
       Cause (2 of 3): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{FileInputStream->Bitmap->Drawable}
       Cause (3 of 3): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{FileInputStream->BitmapDrawable->Drawable}
     Cause (2 of 3): class com.bumptech.glide.load.engine.GlideException: Failed LoadPath{ParcelFileDescriptor->Object->Drawable}, LOCAL
       Cause (1 of 2): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{ParcelFileDescriptor->Bitmap->Drawable}
       Cause (2 of 2): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{ParcelFileDescriptor->BitmapDrawable->Drawable}
     Cause (3 of 3): class com.bumptech.glide.load.engine.GlideException: Failed LoadPath{AssetFileDescriptor->Object->Drawable}, LOCAL
       Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{AssetFileDescriptor->Bitmap->Drawable}

I didn't understand those error messages. Why I'm getting then exactly?

Idea
Hello, I am developing an app that records an audio from smartphone, get this audio recorded and transforms it into a byte array vector. The audio after recording is saved by the smartphone as an audio file named "...audio_record.3gp".

What I'm doing: After using the app to record the audio, I open the app called "File Manager" and go to file "/storage/emulated/0" where the audios recorded with end "..audio_record.3gp" are being saved.

To get this local "path" I'm coding this:

  String path =Environment.getExternalStorageDirectory().getAbsolutePath()+"/"+UUID.randomUUID().toString()+"audio_record.3gp";

Then I get this audio file and converts it into a bytes array vector doing this:

public byte[] convert(String path) throws IOException {

FileInputStream fis = new FileInputStream(path);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte[] b = new byte[1024];

for (int readNum; (readNum = fis.read(b)) != -1; ) {
    bos.write(b, 0, readNum);
}

byte[] bytes = bos.toByteArray();

String decode = Arrays.toString(bytes);
Log.d("mytag", decode);

return bytes;

The audio is being recorded correctly, and saved to the file "/storage/emulated/0". The problem happens when we get the last audio from this file and try to work with it. "*/storage/emulated/0/9fe457b5-7baf-459d-be34-76ec5c2bcf74audio_record.3gp***" is the name of the audio file tried to be loaded.

— alterado em 04/03/2020, 15:31:19

Seja o primeiro a responder
Recomendado pelo NextPit