react-native-sound-player icon indicating copy to clipboard operation
react-native-sound-player copied to clipboard

[BUG] Get info returns Duration that is less then currentTime

Open ahmad6242 opened this issue 3 years ago • 1 comments

Describe the bug I put the getInfo inside SetInterval to get current Time every Second. it return me current time and duration. The duration is wrong that is less than the currentTime image

To Reproduce Using

           setInterval(() => {
                this.getInfo()
            }, 1000);

async getInfo() { // You need the keyword `async`
        try {
            const info = await SoundPlayer.getInfo()
            this.setState({ audioPlayer: { ...this.state.audioPlayer, duration: (info.duration).toFixed(2), currentTime: (info.currentTime).toFixed(2) } })

        } catch (e) {
            console.log('There is no song playing', e)
        }
    }

Expected behavior duration shoould be equal or bigger than the current time.

Platform (please complete the following information): Tested on Android only.

ahmad6242 avatar Oct 10 '21 10:10 ahmad6242

I can't see which audio type you use, but I assume that it takes the current time and duration wrong depending on the file type. I'm recording voice using the mic and saving it as an AAC file. When I got the information, the duration was bigger than it should be. But when I play mp3 files, I can get the sound info correctly.

DeveloperInside avatar Jan 05 '24 01:01 DeveloperInside