juananime / react-native-audiowaveform

Audio waveform renderer for React Native
265 stars 94 forks source link

Stop playing on unmount? #38

Open geraintwhite opened 6 years ago

geraintwhite commented 6 years ago

Thanks for the hard work on this module.

I have run into a couple of issues using this on iOS:

  1. If I try to play the media with onPress before the waveform has appeared (it takes a couple of seconds when using a media URL), the app crashes with the following error:
2018-08-16 14:38:58.755514+0100 CloudVoiceSimple[27007:10505913] SRC ::: {
    isAsset = 0;
    isNetwork = 1;
    mainVer = 0;
    patchVer = 0;
    uri = "https://archive.org/download/testmp3testfile/mpthreetest.mp3";
}
2018-08-16 14:38:58.755723+0100 CloudVoiceSimple[27007:10505913] NSURLRequest :: https://archive.org/download/testmp3testfile/mpthreetest.mp3
2018-08-16 14:38:58.763712+0100 CloudVoiceSimple[27007:10505913] reactSetFrame ::: (null)
2018-08-16 14:38:59.487585+0100 CloudVoiceSimple[27007:10513492] [] nw_connection_get_connected_socket 231 Connection has no connected handler
2018-08-16 14:39:01.402117+0100 CloudVoiceSimple[27007:10505913] *** Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [nan 16.5]'
*** First throw call stack:
(
    0   CoreFoundation                      0x00000001058481e6 __exceptionPreprocess + 294
    1   libobjc.A.dylib                     0x0000000103cec031 objc_exception_throw + 48
    2   CoreFoundation                      0x00000001058bd975 +[NSException raise:format:] + 197
    3   QuartzCore                          0x00000001081ace25 _ZN2CA5Layer12set_positionERKNS_4Vec2IdEEb + 151
    4   QuartzCore                          0x000000010819d52a -[CALayer setPosition:] + 43
    5   QuartzCore                          0x000000010819db58 -[CALayer setFrame:] + 544
    6   UIKit                               0x000000010982c557 -[UIView(Geometry) setFrame:] + 368
    7   CloudVoiceSimple                    0x0000000101ffca25 __34-[OGWaverformView updateProgress:]_block_invoke + 261
    8   UIKit                               0x000000010983f597 +[UIView(UIViewAnimationWithBlocks) _setupAnimationWithDuration:delay:view:options:factory:animations:start:animationStateGenerator:completion:] + 560
    9   UIKit                               0x000000010983fb25 +[UIView(UIViewAnimationWithBlocks) animateWithDuration:animations:] + 48
    10  CloudVoiceSimple                    0x0000000101ffc8d2 -[OGWaverformView updateProgress:] + 642
    11  Foundation                          0x00000001037564dd __NSFireTimer + 83
    12  CoreFoundation                      0x00000001057d7e64 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
    13  CoreFoundation                      0x00000001057d7a52 __CFRunLoopDoTimer + 1026
    14  CoreFoundation                      0x00000001057d760a __CFRunLoopDoTimers + 266
    15  CoreFoundation                      0x00000001057cee4c __CFRunLoopRun + 2252
    16  CoreFoundation                      0x00000001057ce30b CFRunLoopRunSpecific + 635
    17  GraphicsServices                    0x000000010d8fca73 GSEventRunModal + 62
    18  UIKit                               0x000000010977d0b7 UIApplicationMain + 159
    19  CloudVoiceSimple                    0x0000000101cbb18f main + 111
    20  libdyld.dylib                       0x0000000108754955 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 
  1. The audio continues to play when the component is unmounted. Is there anyway to stop it playing on unmount?
geraintwhite commented 5 years ago

You can stop the media playback in the background by setting play to false when the app is in the background using AppState, and when the view is not in focus using withNavigationFocus from react-navigation.

akiotakeis commented 5 years ago

App crashes when trying to start before audio file is loaded and graph is displayed. You can use stop props with grit96 's method, but library didn't implement stop method properly I forked this repo and made a few updates and you can find it from https://github.com/akiotakeis/react-native-audiowaveform

Lemaro86 commented 4 years ago

App crashes when trying to start before audio file is loaded and graph is displayed. You can use stop props with grit96 's method, but library didn't implement stop method properly I forked this repo and made a few updates and you can find it from https://github.com/akiotakeis/react-native-audiowaveform

Cool, but unsupported now

kieran-Collins commented 2 years ago

I have same issue for stop playing on unmount. Tried using play state false on unmount. but when some other audio file is opened the previous audio starts playing again. even I have cleared source data.

iamyahyaahmed commented 1 year ago

This is an important requirement The sound keeps playing :/ Still can stop the sound on unmount