jsierles / react-native-audio

Audio recorder library for React Native
MIT License
1.16k stars 539 forks source link

.onFinished is not fired by AudioRecorder after playback (iOS) #111

Closed tomprogers closed 7 years ago

tomprogers commented 7 years ago

The onFinished method is not fired when using AudioRecorder to play an already-recorded file.

onFinished does fire when recording terminates (on a hardware device).

onProgress does fire during both recording and playback when running the app (on a hardware device).

None of these methods fire in an iOS simulator.

zwrose commented 7 years ago

Similarly, I haven't been able to get onFinished to fire for recording on an Android device. Not sure if this should be a separate issue.

Might have something to do with NativeAppEventEmitter needing special configuration with Android? such as described here: https://github.com/facebook/react-native/issues/7341

jsierles commented 7 years ago

onFinished may be fixed now for Android. Can you test? For playback, in the next version playback will likely be removed completely in favor of using other libraries for this purpose, such as react-native-sound. The goal is to eventually merge with this library.

PranayShah commented 7 years ago

.onFinished is not fired on an Android device as of version 3.1.0. The issue seems to be the return statement here.

Slooowpoke commented 7 years ago

(For Android, with RN 0.40) Not sure if this helps, but I was messing around trying to get it to work. The documentation is a little fuzzy on the difference between NativeAppEventEmitters and DeviceEventEmitters so more info on the difference would be handy. I managed to get it to work with

DeviceEventEmitter.addListener('recordingProgress', (e) => console.log(e));
DeviceEventEmitter.addListener('recordingFinished', (e) => `console.log(e));

in my componentDidMount(). Unfortunately I have a failing ios build (unrelated to this) so I can't test it on there.

Is it something wrong with the way the listener is setup in the example? Cause I can't get it to work from AudioRecorder.onProgress which seems the most pragmatic and sensible solution (especially if DeviceEventEmitter should be used for Android and the other for iOS).

mrThinBone commented 7 years ago

onProgress & onFinished also not fire on Android, did anyone know how to fix it?

cooperka commented 7 years ago

This issue was originally about the callbacks specifically while playing audio (which is no longer a feature), but a few people have mentioned other similar issues. They should be fixed now in https://github.com/jsierles/react-native-audio/pull/150!