-
Notifications
You must be signed in to change notification settings - Fork 747
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not working on Android | number of channels is -1 #203
Comments
change your react-native-sound package dependency by try |
@Winglonelion
|
Can you try this on new version 0.10.2? This should be fixed |
@benvium It worked just the first time but after that i doesn't work ever. After closing the app and reopening, the sound does not work even for the first time too. All the time I am getting the sound played callback though. |
@rohitgoyal Can you have a go with |
Tried it. No sounds in react-native-sound-demo on android too. :-/ |
Which device and OS are you on? |
Google Nexus 6P |
I have the same problem. |
bump |
The same here. Running on android device. |
The same here. |
Anybody has solved the problem? |
solved... just put "music.play()" out of constructor error part, like this.
|
What @DavitVosk means is to put the play() call inside the constructor callback. This has solved playback for me. |
This must be added to the documentation. I'll submit a PR next week. |
And the original title of this issue is:
But that is not the real issue, because it will always return -1 on Android because |
@rohitgoyal Is your problem fixed with the latest version? I see that you already were playing from the onError callback |
@gvenk I got it working while playing from the Main Bundle but it still doesn't work from a dir path. |
@rohitgoyal if you want to get it working from a dir path in the app, you have to remove the second parameter Annoying it's not working on the emulator. I don't have any problem with the emulator, so it's difficult to debug :-( |
@gvenk I did try it after removing the second parameter only. It didn't work on Android but worked on iOS(Check 3rd reply on the thread). On Emulator it might be specific emulator issue as well. I tried on genymotion emulator with following config |
@rohitgoyal ah, I overlooked that comment. Was this on a real device, or emulator? Ah, I don't have access to the genymotion emulator, so I'm not able to debug this, sorry. |
@gvenk On a real device. |
Ok, @rohitgoyal so this issue can be closed according to you? Maybe we have to add a note about which emulators we know are working with this project. |
@gvenk Yeah I guess. You can add the note for sound not playing on emulator and sound not playing on real android device using dir path. |
@gvenk does this relate to switching from |
@trepidity don't think so |
There are a lot of great guys working on this project. Please can someone take a look at this issue. I am trying to play a user selected music file. Take a look at the issue here |
Make sure you give some time between loading your sound and playing it. My "whoosh.play()" was run right after my "var whoosh = new Sound()" which gave me the error. After I split them into two different function and call them separately with some interval, it works its magic. Well at least that was my issue. |
this solved my issue, React = 16.5.2 |
@Faisal-Manzer But does this mean that we have to initiate the same sound as |
Android could not play the sound embedded in the bundle. There is no problem in iOS (even you can initiate the sound once and then use play() function consecutively. |
Im still experiencing this issue on android still. (June 7th, 2021) Device: OnePlus 7Pro - Android 10 I am trying to play from network let s;
// component
() => {
const onPressPlay = () => {
if(playing){
s.pause();
setPlaying(false);
}else{
if(!songLoaded){
setSongLoading(true)
s = new Sound(audio_src, null, (error) => {
if(error){
console.log(e);
Alert.alert("Audio Error", error);
setSongLoading(false);
return;
}
console.log("Success Loading Audio");
console.log('duration in seconds: ' + s.getDuration() + 'number of channels: ' + s.getNumberOfChannels());
setSongLoading(false);
setSongLoaded(true);
s.play((success) => {
if(success){
console.log("Success Playing Audio");
setPlaying(true)
}else{
console.log("Error Playing Audio");
}
})
});
setSongLoaded(true);
}else{
s.play((success) => {
if(success){
console.log("Success Playing Audio");
setPlaying(true)
}else{
console.log("Error Playing Audio");
}
});
}
}
}
} |
Sounds are working on iOS using the below code but not working on Android. I have notification.wav file in the android/app/src/main/res/raw directory. Help please.
On log I am getting this but no sound played. And the number of channels is -1
The text was updated successfully, but these errors were encountered: