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..f15fdb3 100644 --- a/index.js +++ b/index.js @@ -36,12 +36,20 @@ 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) => { - 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) => {