doublesymmetry / react-native-track-player

A fully fledged audio module created for music apps. Provides audio playback, external media controls, background mode and more!
https://rntp.dev/
Apache License 2.0
3.2k stars 984 forks source link

seekTo() make position back to 0 #2140

Closed jimluo123 closed 10 months ago

jimluo123 commented 10 months ago

Describe the Bug A clear and concise description of what the bug is. when I call the seekTo() function. The current Track's progress position is back to 0 again. Platform is Android.

Steps To Reproduce How can someone else reproduce this bug?

Code To Reproduce Please provide a simple code example that allows others to replicate the bug.

         <Slider
                style={{
                  width: "95%",
                  height: 20,
                  alignSelf: "center",
                }}
                minimumValue={0}
                maximumValue={
                  !!currentTrack ? (currentTrack?.duration as number) : 280
                }
                thumbTintColor={"#fff"}
                value={progress.position}
                // onSlidingComplete={(value: number) => {

                // }}
                onValueChange={(value) => {
                  console.log(value);
                  jumpTo(value);
                  console.log("value");
                }}
                step={2}
                tapToSeek={true}
                minimumTrackTintColor={generalProperties.primary}
                maximumTrackTintColor="#6B6B6B"
              />

// I can get the value, but position still start to 0.
const jumpTo = async (value: number) => {
    console.log(value);
    await TrackPlayer.seekTo(value);
  };

Replicable on Example App? Can you replicate this bug in the React Native Track Player Example App?

Environment Info: Paste the results of npx react-native info

System: OS: Windows 10 10.0.22621 CPU: (8) x64 Intel(R) Core(TM) i5-1035G1 CPU @ 1.00GHz Memory: 449.89 MB / 15.67 GB Binaries: Node: version: 16.18.1 path: C:\Program Files\nodejs\node.EXE Yarn: version: 1.22.19 path: ~\AppData\Roaming\npm\yarn.CMD npm: version: 9.7.2 path: C:\Program Files\nodejs\npm.CMD Watchman: Not Found SDKs: Android SDK: Not Found Windows SDK: Not Found IDEs: Android Studio: Not Found Visual Studio:

Paste the exact react-native-track-player version you are using

"react-native-track-player": "^4.0.0-rc09",

Real device? Or simulator?

simulator

What OS are you running?

Android

How I can Help What can you do to help resolve this?

I can provide some pieces of code where the problem happened.

Have you investigated the underlying JS or Swift/Android code causing this bug? Can you create a Pull Request with a fix? No.

jimluo123 commented 10 months ago

I have found out what causes this problem. Because of the song file's quality, I can not get the second position immediately.