zmxv / react-native-sound

React Native module for playing sound clips
MIT License
2.78k stars 749 forks source link

-1: resource not found on Android after Code Push both when using relative and absolute paths #656

Open EmperorEarth opened 4 years ago

EmperorEarth commented 4 years ago

:beetle: Description

Similar to #643 but iPhone works fine.

Sound plays on normal build. After any react-native-code-push update, the iPhone app continues to work fine but the Android app is no longer able to find the file. This happens even in updates unrelated to react-native-sound.

:beetle: What is the observed behavior?

On Android, after any code push update, react-native-sound returns error {code: -1, message: "resource not found"}.

:beetle: What is the expected behavior?

No error.

:beetle: Please post your code:

import Sound from "react-native-sound";
Sound.setCategory("Playback");
const _loudBang = new Sound(require("./loudbang.mp3"));
_loudBang.play();

and

import Sound from "react-native-sound";
Sound.setCategory("Playback");
const _loudBang = new Sound("loudbang.mp3", Sound.MAIN_BUNDLE);
_loudBang.play();

Is your issue with...

Are you using...

Which versions are you using?

Does the problem occur on...

Additional comment

Exact same behavior on react-native 0.59.10 + react-native-code-push 5.7.0. Likely same issue. Same behavior both when using absolute and relative paths.

EmperorEarth commented 4 years ago

This should be labeled with android and bug. I'm not sure how I labeled this issue question label nor how to change it.

pankajgupta1 commented 4 years ago

I am facing the same problem with codepush

pankajgupta1 commented 4 years ago

Hi with relative path with code push that is not working.

I copied my audio files in android/app/src/main/res/raw folder. And I used

const whoosh = new Sound('abc.mp3', Sound.MAIN_BUNDLE, (error) => {
    if (error) {
      return;
    }
    whoosh.play((success) => {
      whoosh.release()
    });
  });

This worked perfectly for me with codepush, for android.

dungnguyentri3110 commented 3 years ago

Guys! Does anyone have any solution???

ashwini-ksingh commented 3 years ago

Is there a solution for this? I have mp3 in npm dependency, and its not working after codepush release (works perfectly with apk).

Platform: Android