react-native-sound-player
react-native-sound-player copied to clipboard
[BUG] Get info returns Duration that is less then currentTime
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
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.
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.