react-native-sound-player icon indicating copy to clipboard operation
react-native-sound-player copied to clipboard

[iOS] Problem listening FinishedLoading & FinishedPlaying

Open HugoEdd opened this issue 2 years ago • 5 comments

I have a warning message on IOS devices, I created a general function. I do not how to avoid that warning. This is my function let onFinishedPlaying = null;

export const playButtonSound = (sound: SoundNames, format: SoundFormat) => { onFinishedPlaying = SoundPlayer.addEventListener( 'FinishedPlaying', ({ success }) => { console.log('finished playing', success); }, );

// Llamar a la función playSoundFile SoundPlayer.playSoundFile(sound, format); console.log('Reproduciendo');

// Eliminar las suscripciones después de su uso onFinishedPlaying.remove(); console.log('removiendo'); };

Of this way I call it into other screens

playButtonSound(SoundNames.CartLimit, MP3);

warning message: Sending FinishedPlaying with no listeners registered.

HugoEdd avatar Nov 03 '23 16:11 HugoEdd

@HugoEdd It looks like you're removing the handler before it had finished playing the sound, so you're getting an expected warning of no listeners upon that event. I believe remove() would be for cleanup of used listeners. If you just want to eliminate the warning, probably just use SoundPlayer.addEventListener('FinishedPlaying', ({ success }) => {})

kendistiller avatar Nov 19 '23 22:11 kendistiller

not working

remove is not there in latest release

MuhammadAdeelBaig avatar Jan 03 '24 06:01 MuhammadAdeelBaig

I had this problem because the audio path was wrong. When I fixed it, the listener worked fine.

JoaoNeto99 avatar Jan 05 '24 12:01 JoaoNeto99

same problem not working in ios ......

sahiljnv avatar May 02 '24 04:05 sahiljnv

same problem

not working in ios ......

Please provide your code as the latest works fine for me.

kendistiller avatar May 02 '24 16:05 kendistiller