Skip to content
This repository has been archived by the owner on Dec 14, 2020. It is now read-only.

currentTime and duration features not working #4

Open
Arkanine opened this issue Jan 27, 2017 · 11 comments
Open

currentTime and duration features not working #4

Arkanine opened this issue Jan 27, 2017 · 11 comments

Comments

@Arkanine
Copy link

Arkanine commented Jan 27, 2017

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

@victor36max
Copy link
Member

Hi,

Can I see what's the error message like when the app crashed?

@Arkanine
Copy link
Author

Sure, one of them is
screen shot 2017-01-30 at 9 45 56 am

@livelyjp
Copy link

livelyjp commented Feb 3, 2017

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

@qpowell
Copy link

qpowell commented Feb 7, 2017

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

@qpowell
Copy link

qpowell commented Feb 23, 2017

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?

@victor36max
Copy link
Member

@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

@victor36max
Copy link
Member

@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

@victor36max
Copy link
Member

@qpowell I have made this fix to further check if the observer is removed when dealloc. Hopefully it will fix the problem

@ariona
Copy link

ariona commented Mar 30, 2017

Hi @victor36max, any update on this? I am using 0.0.7 yet still get negative number for audio duration in Android?

@ghost
Copy link

ghost commented Nov 16, 2017

You need to wait for the status change to 'PLAY/PAUSE' -- then it will give the proper duration of the song.

@ithustle
Copy link

ithustle commented Nov 11, 2018

@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?

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

No branches or pull requests

6 participants