Skip to content

Commit

Permalink
Merge pull request #169 from cixio/android-release-fix
Browse files Browse the repository at this point in the history
fix android release bug
  • Loading branch information
johnsonsu authored Jun 6, 2024
2 parents 557bc95 + da28c6f commit 8abafcb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 11 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit 8abafcb

Please sign in to comment.