Skip to content

Commit

Permalink
Avoid crash when play audio
Browse files Browse the repository at this point in the history
  • Loading branch information
hans00 committed Dec 24, 2023
1 parent ca5b47c commit 260342c
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions patches/react-native-sound-player+0.13.2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
diff --git a/node_modules/react-native-sound-player/android/src/main/java/com/johnsonsu/rnsoundplayer/RNSoundPlayerModule.java b/node_modules/react-native-sound-player/android/src/main/java/com/johnsonsu/rnsoundplayer/RNSoundPlayerModule.java
index 2a1561c..dd3834e 100644
--- a/node_modules/react-native-sound-player/android/src/main/java/com/johnsonsu/rnsoundplayer/RNSoundPlayerModule.java
+++ b/node_modules/react-native-sound-player/android/src/main/java/com/johnsonsu/rnsoundplayer/RNSoundPlayerModule.java
@@ -164,6 +164,8 @@ public class RNSoundPlayerModule extends ReactContextBaseJavaModule implements L
this.mediaPlayer = MediaPlayer.create(getCurrentActivity(), this.getUriFromFile(name, type));
}

+ if (this.mediaPlayer == null) return
+
this.mediaPlayer.setOnCompletionListener(
new OnCompletionListener() {
@Override
@@ -217,6 +219,7 @@ public class RNSoundPlayerModule extends ReactContextBaseJavaModule implements L
if (this.mediaPlayer == null) {
Uri uri = Uri.parse(url);
this.mediaPlayer = MediaPlayer.create(getCurrentActivity(), uri);
+ if (this.mediaPlayer == null) return
this.mediaPlayer.setOnCompletionListener(
new OnCompletionListener() {
@Override

0 comments on commit 260342c

Please sign in to comment.