Open Arkanine opened 7 years ago
Hi,
Can I see what's the error message like when the app crashed?
Sure, one of them is
I have also experienced this except the method didnt crash the App. RN: 0.36.1 Android
Calling duration/currentTime during playback returns the correct value
Same thing happened to me, here's the logger output:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'An instance 0x6000000b1580 of class DOUAudioStreamer was deallocated while key value observers were still registered with it. Current observation info: <NSKeyValueObservationInfo 0x61000042cf80> (
<NSKeyValueObservance 0x610000246cc0: Observer: 0x61000042c040, Key path: status, Options: <New: YES, Old: NO, Prior: NO> Context: 0x102af1ce8, Property: 0x610000245be0>
)'
*** First throw call stack:
(
0 CoreFoundation 0x0000000104836d4b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00000001032c221e objc_exception_throw + 48
2 CoreFoundation 0x00000001048a02b5 +[NSException raise:format:] + 197
3 Foundation 0x0000000102df6ba1 NSKVODeallocate + 293
4 libobjc.A.dylib 0x00000001032d6b12 _ZN11objc_object17sidetable_releaseEb + 212
5 Testapp 0x0000000102a3c9ef -[DOUAudioEventLoop _eventLoop] + 415
6 Testapp 0x0000000102a3cb7f event_loop_main + 63
7 libsystem_pthread.dylib 0x0000000108dfeaab _pthread_body + 180
8 libsystem_pthread.dylib 0x0000000108dfe9f7 _pthread_body + 0
9 libsystem_pthread.dylib 0x0000000108dfe1fd thread_start + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Any update on this? In the interest of time, I decided to use something else for iOS audio playback but still attempting to use this on Android.
Getting the currentTime
works for me now, but trying to get the duration using the following code returns -9223372036854776
, on multiple audio files.
RNAudioStreamer.duration((err, duration) => {
if (err) { console.log('error:', err) }
console.log('duration: ', duration);
});
I'm thinking it may be due to the audio file not being loaded enough to calculate the duration. If I wrap the code above in a setTimeout, and wait a few seconds, it seems to work. Maybe I should hold off on calculating the duration until the status changes from BUFFERING
to PLAYING
?
@qpowell i have just made a fix to further check & avoid current time/duration to show negative number. Please let me know if problem still exists
@Arkanine this looks like a problem from the audio lib DOUAudioStreamer this modile is based on. I had considered to use some other libs. But only this one gives me possibility to do audio caching
@qpowell I have made this fix to further check if the observer is removed when dealloc. Hopefully it will fix the problem
Hi @victor36max, any update on this? I am using 0.0.7 yet still get negative number for audio duration in Android?
You need to wait for the status change to 'PLAY/PAUSE' -- then it will give the proper duration of the song.
@victor36max I have the same problem in Android. On iOS return 0. I created a method called prepare()
, inside I call RNAudioStreamer.setUrl(myUrl);
and then, when status change from BUFFERING to PAUSED, I call RNAudioStreamer.play()
inside my method called_play()
. For the first time it works but when I hit to change to another music, the duration return a negative value.
So, what is the best way to use this package?
Hi, Looks like currentTime and duration features not working, they return 0. The duration method crash application. Also would be great to know how to stop the audio? Tested on RN 32.1 Android and iOS platforms