From ecc78fa5f666ba48775cceb73506e70588e67d77 Mon Sep 17 00:00:00 2001 From: cixio <5869764+cixio@users.noreply.github.com> Date: Wed, 5 Jun 2024 22:01:49 +0200 Subject: [PATCH 1/2] fix android release bug --- .../com/johnsonsu/rnsoundplayer/RNSoundPlayerModule.java | 2 +- index.js | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/android/src/main/java/com/johnsonsu/rnsoundplayer/RNSoundPlayerModule.java b/android/src/main/java/com/johnsonsu/rnsoundplayer/RNSoundPlayerModule.java index de48497..f8c4f2a 100644 --- a/android/src/main/java/com/johnsonsu/rnsoundplayer/RNSoundPlayerModule.java +++ b/android/src/main/java/com/johnsonsu/rnsoundplayer/RNSoundPlayerModule.java @@ -190,7 +190,7 @@ private void mountSoundFile(String name, String type) throws IOException { private Uri getUriFromFile(String name, String type) { String folder = getReactApplicationContext().getFilesDir().getAbsolutePath(); - String file = name + "." + type; + String file = (!type.isEmpty()) ? name + "." + type : name; // http://blog.weston-fl.com/android-mediaplayer-prepare-throws-status0x1-error1-2147483648 // this helps avoid a common error state when mounting the file diff --git a/index.js b/index.js index c663a60..61609fd 100644 --- a/index.js +++ b/index.js @@ -36,8 +36,12 @@ export default { RNSoundPlayer.loadUrl(url); }, - playAsset: (asset: number) => { - RNSoundPlayer.playUrl(resolveAsset(asset).uri); + playAsset: async (asset: number) => { + if (!(__DEV__) && Platform.OS === "android") { + RNSoundPlayer.playSoundFile(resolveAsset(asset).uri, ''); + } else { + RNSoundPlayer.playUrl(resolveAsset(asset).uri); + } }, loadAsset: (asset: number) => { From da28c6f35e30a36f3fcbd8269f315ab03ab78805 Mon Sep 17 00:00:00 2001 From: cixio <5869764+cixio@users.noreply.github.com> Date: Wed, 5 Jun 2024 22:07:33 +0200 Subject: [PATCH 2/2] fix for loadAsset --- index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 61609fd..f15fdb3 100644 --- a/index.js +++ b/index.js @@ -45,7 +45,11 @@ export default { }, loadAsset: (asset: number) => { - RNSoundPlayer.loadUrl(resolveAsset(asset).uri); + if (!(__DEV__) && Platform.OS === "android") { + RNSoundPlayer.loadSoundFile(resolveAsset(asset).uri, ''); + } else { + RNSoundPlayer.loadUrl(resolveAsset(asset).uri); + } }, onFinishedPlaying: (callback: (success: boolean) => any) => {