johnsonsu / react-native-sound-player

Play sound file in ReactNative
MIT License
253 stars 91 forks source link

Attempt to invoke virtual method [BUG] #95

Open kirtan96 opened 4 years ago

kirtan96 commented 4 years ago

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

anujec722 commented 4 years ago

same problem how to fix it

DanielMarcello commented 4 years ago

@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 commented 4 years ago

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);

lundn commented 4 years ago

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

perfecten commented 4 years ago

I have the same issue

ajiehatajie commented 4 years ago

I have the same issue

bonfimjustino7 commented 3 years ago

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