Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[startPlayer] addPlayBackListener e.currentPosition value have minus at the beginning. #639

Open
dmk3141618 opened this issue Nov 5, 2024 · 1 comment

Comments

@dmk3141618
Copy link

Please fill the template to help you out. Also, please try the Example project compare before submiting the issue when you have certain issue with your project setup.

Version of react-native-audio-recorder-player

"react-native-audio-recorder-player": "^3.6.12",

Version of React Native

"react-native": "0.76.0",

Platforms you faced the error (IOS or Android or both?)

iOS

Expected behavior

Always Return currentPosition > 0

Actual behavior

minus value at the beginning

LOG e: {"currentPosition": 0, "duration": 2414.8752834467123, "isFinished": false, "isMuted": false}
LOG e: {"currentPosition": -52.358135, "duration": 2414.8752834467123, "isFinished": false, "isMuted": false}
LOG e: {"currentPosition": -52.075718, "duration": 2414.8752834467123, "isFinished": false, "isMuted": false}

LOG e: {"currentPosition": 100.633699, "duration": 2414.8752834467123, "isFinished": false, "isMuted": false}
LOG e: {"currentPosition": 200.825949, "duration": 2414.8752834467123, "isFinished": false, "isMuted": false}
LOG e: {"currentPosition": 301.405949, "duration": 2414.8752834467123, "isFinished": false, "isMuted": false}
LOG e: {"currentPosition": 401.285615, "duration": 2414.8752834467123, "isFinished": false, "isMuted": false}
LOG e: {"currentPosition": 501.37999, "duration": 2414.8752834467123, "isFinished": false, "isMuted": false}
LOG e: {"currentPosition": 601.3762820000001, "duration": 2414.8752834467123, "isFinished": false, "isMuted": false}
LOG e: {"currentPosition": 701.390824, "duration": 2414.8752834467123, "isFinished": false, "isMuted": false}
LOG e: {"currentPosition": 801.38199, "duration": 2414.8752834467123, "isFinished": false, "isMuted": false}
LOG e: {"currentPosition": 901.086824, "duration": 2414.8752834467123, "isFinished": false, "isMuted": false}
LOG e: {"currentPosition": 1000.397531, "duration": 2414.8752834467123, "isFinished": false, "isMuted": false}
LOG e: {"currentPosition": 1101.218685, "duration": 2414.8752834467123, "isFinished": false, "isMuted": false}
LOG e: {"currentPosition": 1201.352258, "duration": 2414.8752834467123, "isFinished": false, "isMuted": false}
LOG e: {"currentPosition": 1301.3203310000001, "duration": 2414.8752834467123, "isFinished": false, "isMuted": false}
LOG e: {"currentPosition": 1401.269613, "duration": 2414.8752834467123, "isFinished": false, "isMuted": false}
LOG e: {"currentPosition": 1501.3891859999999, "duration": 2414.8752834467123, "isFinished": false, "isMuted": false}
LOG e: {"currentPosition": 1601.3535100000001, "duration": 2414.8752834467123, "isFinished": false, "isMuted": false}
LOG e: {"currentPosition": 1701.2976259999998, "duration": 2414.8752834467123, "isFinished": false, "isMuted": false}
LOG e: {"currentPosition": 1801.2382, "duration": 2414.8752834467123, "isFinished": false, "isMuted": false}
LOG e: {"currentPosition": 1901.358273, "duration": 2414.8752834467123, "isFinished": false, "isMuted": false}
LOG e: {"currentPosition": 2001.325218, "duration": 2414.8752834467123, "isFinished": false, "isMuted": false}
LOG e: {"currentPosition": 2101.3515909999996, "duration": 2414.8752834467123, "isFinished": false, "isMuted": false}
LOG e: {"currentPosition": 2201.446256, "duration": 2414.8752834467123, "isFinished": false, "isMuted": false}
LOG e: {"currentPosition": 2301.385463, "duration": 2414.8752834467123, "isFinished": false, "isMuted": false}
LOG e: {"currentPosition": 2401.294711, "duration": 2414.8752834467123, "isFinished": false, "isMuted": false}
LOG e: {"currentPosition": 2414.8752834467123, "duration": 2414.8752834467123, "isFinished": false, "isMuted": false}
LOG e: {"currentPosition": 2414.8752834467123, "duration": 2414.8752834467123, "isFinished": true, "isMuted": false}

Steps to reproduce the behabior

Execute main example

@dmk3141618
Copy link
Author

So I am using if guard to prevent to show minus value.

      const msg = await audioRecorderPlayer.current.startPlayer(fileUriPlay);
      const volume = await audioRecorderPlayer.current.setVolume(1.0);
      console.log(`path: ${msg}`, `volume: ${volume}`);

      audioRecorderPlayer.current.addPlayBackListener((e: PlayBackType) => {
        console.log('e: ', e);
        if (e.currentPosition < 0) return;
        setState(prev => ({
          ...prev,
          currentPositionSec: e.currentPosition,
          currentDurationSec: e.duration,
          playTime: audioRecorderPlayer.current.mmssss(
            Math.floor(e.currentPosition),
          ),
          duration: audioRecorderPlayer.current.mmssss(Math.floor(e.duration)),
        }));
      });

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

No branches or pull requests

1 participant