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

Rapidly toggling "Play" and "Pause" causes incorrect audio player behavior #152

Open
Abdullo-0901 opened this issue Jan 3, 2025 · 1 comment

Comments

@Abdullo-0901
Copy link

FILE.2025-01-03.21.31.28.mp4
FILE.2025-01-03.21.31.29.mp4

When rapidly switching between Play and Pause states in the audio player, the following issues are observed:

The PlayerState transitions multiple times incorrectly.
The timer (progress) value resets to 0 unexpectedly or behaves incorrectly.
Logs frequently show EVENT values as 0, which disrupts the expected progress tracking.

  <Pressable onPress={() => onStartPlay()} hitSlop={30}>
          <Icon
            bald
            name={
              playerState === PlayerState.playing
                ? "fa-solid fa-pause"
                : "fas fa-play"
            }

            fill={styles.scrubColor.color}
            width={12}
            height={16}
          />
        </Pressable>
        <Waveform
          ref={ref}
          path={`${pathAudio.path}`}
          key={pathAudio.path}
          candleSpace={2}
          candleWidth={2}
          containerStyle={styles.containerStyle}
          playbackSpeed={1}
          waveColor={styles.waveColor.color}
          scrubColor={styles.scrubColor.color}
          mode={"static"}
          candleHeightScale={26}
          onPanStateChange={() => {
            playerState === PlayerState.stopped ? true : false
          }}
          onPlayerStateChange={(state: PlayerState) => {
            console.log("Player State Changed:", state)
            if (state === PlayerState.stopped) {
              console.log("Progress reset to 0 because player stopped.")
            }
            setPlayerState(state)
          }}
          onError={(error) => {
            console.log(error, "Error in wavefrom")
          }}
          onChangeWaveform

https://github.com/user-attachments/assets/404ff169-a8e1-44ec-b692-6e42f807b6ea

LoadState={(state) => {
            console.log("Loading...", state)
          }}
          onCurrentProgressChange={(event) => {
            console.log("====================================")
            console.log("EVENT", event)
            console.log("====================================")
            setTimer(event)
          }}
        />
          async function onStartPlay() {
      if (!ref.current) return
      ref.current.startPlayer({ finishMode: FinishMode.stop })
      if (playerState === PlayerState.playing) {
        await ref.current.pausePlayer()
      } else {
        await ref.current.resumePlayer()
      }
    }

LOG  Player State Changed: playing
LOG  ====================================
LOG  EVENT 5124
LOG  ====================================
LOG  Player State Changed: paused
LOG  ====================================
LOG  EVENT 0
LOG  ====================================
LOG  Player State Changed: playing
LOG  ====================================
LOG  EVENT 5253
LOG  ====================================
@Abdullo-0901
Copy link
Author

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