Skip to content
This repository has been archived by the owner on Sep 22, 2022. It is now read-only.

Progress bar not animating #12

Closed
JeremyPacker opened this issue Mar 4, 2018 · 9 comments
Closed

Progress bar not animating #12

JeremyPacker opened this issue Mar 4, 2018 · 9 comments

Comments

@JeremyPacker
Copy link

Hello,

I tried running this in an application and for whatever reason I can't get the progress bar to animate up. It just stays flat. I have checked the bytes, and things look good. I even tried the static bytes array in your sample app with no prevail. Thank you!

Here is my code
` mBeatWaveFormIV.setRawData(getByte(mAudioFile.getAbsolutePath()), new OnSamplingListener() {
@OverRide
public void onComplete() {
Log.d("audio", "Completed");
}
});

private byte[] getByte(String path) {
byte[] getBytes = {};
try {
File file = new File(path);
getBytes = new byte[(int) file.length()];
InputStream is = new FileInputStream(file);
is.read(getBytes);
is.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Log.d("Bytes", getBytes.length+"");
return getBytes;
}

03-04 02:06:52.760 18245-18245/me.rapchat.rapchat D/Bytes: 3048734
`

@alxrm
Copy link
Owner

alxrm commented Mar 4, 2018

Hey @JeremyPacker, that's pretty odd, I'll check this issue ASAP and will reply with more concrete explanation(or fix)

@JeremyPacker
Copy link
Author

Thanks for the quick response @alxrm , if you need any more information let me know and i'll get you anything you need!

@JeremyPacker
Copy link
Author

After some more debugging I realized the file that I was calling this method on the path prior to it being decoded to PCM / Raw data. Assuming it wouldn't work for encoded data, I switched that up, I was able to get it to display!

@alxrm
Copy link
Owner

alxrm commented Mar 4, 2018

Glad everything ended up good

@laurentiusandre
Copy link

Hi @JeremyPacker could you explain what did you do eventually? I'm getting the same flat bars. Tried a 200kb mp3 and 1.5mb wav, resulting byte array looks okay but the bars stay flat.

These are the 2 different methods I tried to use to get the byte array:

        static byte[] convertStreamToByteArray(InputStream is) throws IOException {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            byte[] buff = new byte[10240];
            int i = Integer.MAX_VALUE;
            while ((i = is.read(buff, 0, buff.length)) > 0) {
                baos.write(buff, 0, i);
            }
            return baos.toByteArray();
        }
        static byte[] toByteArray(InputStream in) throws IOException {
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            int read = 0;
            byte[] buffer = new byte[1024];
            while (read != -1) {
                read = in.read(buffer);
                if (read != -1)
                    out.write(buffer,0,read);
            }
            out.close();
            return out.toByteArray();
        }

And when I set the raw data, onComplete does not get called:

                waveView.setRawData(soundBytes, new OnSamplingListener() {
                    @Override
                    public void onComplete() {
                        Log.d(TAG, "asdasd");
                    }
                });

Thanks in advance!

@alxrm
Copy link
Owner

alxrm commented May 11, 2018

@laurentiusandre hey, let me test the sample app first

@alxrm
Copy link
Owner

alxrm commented May 11, 2018

@laurentiusandre so I just tested this and it worked just as intended:

    final Random random = new Random();
    final byte[] data = new byte[1024 * 200];
    random.nextBytes(data);

    waveView.setRawData(data, new OnSamplingListener() {
      @Override public void onComplete() {
        Log.e("DBG", "Done downsampling");
      }
    });

Logs showed:

rm.com.audiogram E/DBG: Done downsampling

@alxrm
Copy link
Owner

alxrm commented May 11, 2018

I'm going to update sample activities a bit, so they will make a bit more sense

@laurentiusandre
Copy link

Okay so I tried your code with Random byte array but I still couldn't get it work. I did some testing and it seems like the bars isn't getting updated because I placed it inside a ViewAnimator (inside a nested RecyclerView but I don't think RV is the problem). Could you take a look at this?

I can use other ViewGroup for a workaround, but you may want to solve this odd bug for future users. Thanks for the great library!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants