SimformSolutionsPvtLtd / react-native-audio-waveform

React Native component to show audio waveform with ease in react native application ✨
MIT License
97 stars 7 forks source link

Wrong Duration Calculation and Gesture error #46

Closed ashfaq-ahmed closed 1 week ago

ashfaq-ahmed commented 2 months ago

Hi, thanks for the work. I am using this in a react native project and was facing a few issues that I wanted to get help with. Here is my code

<Waveform
                        mode="static"
                        ref={playerRef}
                        path={ audio.path}
                        onPlayerStateChange={(state) => setPlayerState(state)}
                        containerStyle={{ flex: 1, height: 40}}
                        candleSpace={3}
                        candleHeightScale={7}
                        waveColor='#BABABA'
                        scrubColor={props.isOutbound ? Colors.black : Colors.white}
                        candleWidth={3}
                        onCurrentProgressChange={(currentProgress: number, songDuration: number) => {
                            setSoundDuration(formatMilliseconds(songDuration));
                            setSoundProgress(formatMilliseconds(currentProgress));
                        }}
                        onError={(error) => console.log(error)}
                    />

This is the format of the audio path /storage/emulated/0/Download/Aq13PXxGzF.m4a I tried changing it to file:// format but the app started crashing

  1. The library gives wrong duration of the audio files (specially when I go to same screen second time, it gives zero).
Screenshot 2024-06-22 at 10 50 00 AM
  1. Some times I get back negative duration

    Screenshot 2024-06-22 at 12 13 43 PM
  2. In a FlatList , if I try to scroll by placing the finger on waveform, I get this error

    Screenshot 2024-06-22 at 12 12 05 PM

I am using react-native 0.74.1

mukesh-simform commented 2 months ago

@ashfaq-ahmed Thank you for your interest in this library and for reporting this issue. we will surely look into it and resolve this as soon as possible. Feel free to fork this and fix the issue and raise PR. we always welcome PRs that strengthen this library and increase its usability.

mukesh-simform commented 2 months ago

@ashfaq-ahmed For issue 1 and Issue 3, You can consider these changes in your node modules and confirm once. Let us know if this persists for you. Also could you please explain a bit more about Issue 2, it's working as expected and we're not getting any negative values.