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

Attempt to invoke virtual method [BUG]

Open kirtan96 opened this issue 5 years ago • 7 comments

Describe the bug BUG: Attempt to invoke virtual method 'void android.media.MediaPlayer.setOnCompletionListener(android.media.MediaPlayer$OnCompletionListener)' on a null object reference

SoundPlayer.loadUrl(file.location);

Trying to play an audio file from Android device, specific location on emulator: "content://com.android.providers.downloads.documents/document/raw%3A%2Fstorage%2Femulated%2F0%2FDownload%2FTest.mp3" but I get the following error:

Screen Shot 2020-05-16 at 11 34 12 PM

  • OS: Android Emulator

kirtan96 avatar May 17 '20 06:05 kirtan96

same problem how to fix it

anujec722 avatar Jun 12 '20 04:06 anujec722

@anujec722, I had the same problem and I solved just setting the VIBRATE permission in AndroidManifest.xml. just add <uses-permission android:name="android.permission.VIBRATE"/> and build again. I have not tested that in iOS but in Android works fine 👍

DanielMarcello avatar Aug 05 '20 23:08 DanielMarcello

maybe the problem is for another part, in my case besides playing a sound I also make a vibration SoundPlayer.playSoundFile("beep", "mp3"); Vibration.vibrate(500);

DanielMarcello avatar Aug 05 '20 23:08 DanielMarcello

Seems like the same thing we're experiencing in #100, with SoundPlayer.loadSoundFile

lundn avatar Aug 20 '20 20:08 lundn

I have the same issue

perfecten avatar Sep 11 '20 08:09 perfecten

I have the same issue

ajiehatajie avatar Sep 28 '20 07:09 ajiehatajie

I added my mp3 into android/app/src/main/res/raw and it worked.

bonfimjustino7 avatar Apr 12 '21 18:04 bonfimjustino7