I have issue with resume sound after pausing it.
I want to make play pause resume sound.
🪲 The code:
//SoundManager util that i made.
import Sound from "react-native-sound";
const sounds = {
"crow_sound": {
sound: "people-talking-2.mp3",
path: "https://www.pacdv.com/sounds/people_sound_effects"
},
"sally_sound": {
sound: require("./../../assets/sounds/sallysound.mp3")
},
};
class SoundManager {
playUserReview(name) {
try {
var sound = sounds[name].sound;
var path = sounds[name].path;
if (path) {
this.userReview = new Sound(sound, path, error => {
if (error) {
return;
}
this.userReview.play(success => {
if (!success) {
this.userReview.reset();
}
});
});
} else {
this.userReview = new Sound(sound, error => {
if (error) {
return;
}
this.userReview.play(success => {
if (!success) {
this.userReview.reset();
}
});
});
}
} catch (error) {
console.log(error);
}
}
pauseUsersReviews() {
try {
this.userReview.pause(success => {
if (!success) {
this.userReview.reset();
}
});
} catch (error) {
console.log(error);
}
}
resumeUserReview() {
this.userReview.play((success) => {
success ? console.warn("success") : console.warn("NotSuccess")
});
}
}
module.exports = new SoundManager();
-----------------------
//and this is the function that i used onpress play/pause button.
userNameForPlayingRelatedSound = (username) => {
if(this.state.soundStatus == "notPlayed") {
SoundManager.playUserReview(username);
this.setState({soundStatus: "played"});
console.warn("played");
}
else if(this.state.soundStatus == "played") {
SoundManager.pauseUsersReviews();
this.setState({soundStatus: "paused"})
console.warn("paused");
}
else if(this.state.soundStatus == "paused") {
SoundManager.resumeUserReview();
this.setState({soundStatus: "played"})
console.warn("resume");
}
}
💡 Possible solution
Is your issue with...
Are you using...
Which versions are you using?
- React Native Sound: last version
- React Native: ^0.59.10
- iOS:
- Android: 9
Does the problem occur on...
If your problem is happening on a device, which device?
I have issue with resume sound after pausing it.
I want to make play pause resume sound.
🪲 The code:
💡 Possible solution
Is your issue with...
Are you using...
react-native run-android)Which versions are you using?
Does the problem occur on...
If your problem is happening on a device, which device?