zmxv / react-native-sound

React Native module for playing sound clips
MIT License
2.79k stars 748 forks source link

getDuration return wrong values when playing from file, which is downloading #637

Open zvs001 opened 4 years ago

zvs001 commented 4 years ago

:beetle: Description

I do download audio source with:

 RNFetchBlob.config({
      path: this.path,
      fileCache: true,
 }).fetch('GET', url)

When I downloaded at least something I create Sound instance and start playing audio from file path. An this moment sound.getDuration() returns ~16 seconds, which is correct.

Source continue downloading and sound keep playing. Doesn't matter how many time it will play, but getDuration keep returning 16 seconds. Even when current position is 5 minutes.

When I restart device with cached file (download is finished), it will return real total value. (example: 6mins)

:beetle: What is the expected behavior?

It will return correct value. I expect to get different value in downloading process. (between 16sec and 6mins)

:beetle: Please post your code:

Code is same like in docs

:bulb: Possible solution

Seems like sound instance keeps value of initial duration, and just continue returning it. Maybe this behavior is ok for you. I'd like to be able to do force duration get.

:bulb: Is there a workaround?

I tried to create different instance of Sound just for getting duration, when file upload is finished. But I got error: ENSOSSTATUSERRORDOMAIN-10875

:bulb: If the bug is confirmed, would you be willing to create a pull request?

No

Is your issue with...

Are you using...

Which versions are you using?

Does the problem occur on...

If your problem is happening on a device, which device?

I think it happens on any device