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

onEnd callback is not fired on Android if setSpeed() #837

Open
5 tasks
benhkwoo opened this issue Jan 15, 2024 · 4 comments
Open
5 tasks

onEnd callback is not fired on Android if setSpeed() #837

benhkwoo opened this issue Jan 15, 2024 · 4 comments
Labels

Comments

@benhkwoo
Copy link

🪲 Description

onEnd callback is not fired on Android if setSpeed()

🪲 What is the observed behavior?

onEnd callback is not fired on Android if setSpeed() before play().

🪲 Please post your code:

var whoosh = new Sound('whoosh.mp3', Sound.MAIN_BUNDLE, (error) => {
  if (error) {
    console.log('failed to load the sound', error);
    return;
  }

  whoosh.setSpeed(NUMBER)

  whoosh.play((success) => {
  // onEnd callback will not fire if I set speed before play(). It occurs only on Android

    if (success) {
      console.log('successfully finished playing');
    } else {
      console.log('playback failed due to audio decoding errors');
    }
  });
});

Is your issue with...

  • iOS
  • [V] Android
  • Windows

Are you using...

  • [V] React Native CLI (e.g. react-native run-android)
  • Expo
  • Other: (please specify)

Which versions are you using?

  • React Native Sound: 0.11.2
  • React Native: 0.72.4
  • iOS: 17.x (working properly)
  • Android: version: 14, API: 34
  • Windows: Did not test.

Does the problem occur on...

  • Simulator
  • [V] Device

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

  • Device: SM-G998N
@Alaaeldin-as1405124
Copy link

Alaaeldin-as1405124 commented Jun 14, 2024

I'm having the exact same issue, with setPitch as well

@hptung
Copy link

hptung commented Jun 20, 2024

I'm have the same issue too, have you any solutions?

@hptung
Copy link

hptung commented Jun 20, 2024

Try this code!!

const play = async (soundInit, callBack, isSlow) => {
if (soundInit) {
try {
Sound.setCategory('Playback');

        if (isSlow)
            soundInit.setSpeed(0.7)
        soundInit.play(callBack);

        if (isSlow && Platform.OS === 'android') {
            setTimeout(() => {
                console.log(soundInit.getDuration())
                callBack()
            }, soundInit.getDuration() * 1000);
        }

    } catch (error) {
        console.log(error);
    }
}

};

@PhuongThan25503
Copy link

i get the same issue

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

No branches or pull requests

4 participants