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

浪子不回头ぞ 提交于 2020-01-25 09:17:27

问题


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 tryed to be loaded.

More information you can find and help me here: (1) How to solve this error: Android resource linking failed? or (2) How to convert Bytes Array to a String in order to see it printed onto the console?

来源:https://stackoverflow.com/questions/59772285/glide-fails-to-load-resources-when-trying-to-load-an-audio-file-from-smartphone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!