we are trying to build an app with a player that will work perfectly.
it has a pause button and play.
I have now two problem with my player:
- It plays the sound file I send through the props only one time!
- it ignors other sound files I send it.
I tried to solve it with the AV - Expo Documantation (initialStatuse, ect…) but didnt succeed with the codes gives there.
My code:
const playing = false;
render() {
return (
<View>
<Card wrapperStyle={{ width: 346, height: 180 }}>
<View style={{ flexDirection: "row" }}>
<Text style={styles.resultsContainer}>
{this.state.song.Song_Name}{" "}
</Text>
<Image
style={styles.imageContainer}
source={{ uri: this.state.song.Image }}
/>
</View>
<View style={styles.buttonRow}>
<Ionicons
name="md-play"
size={40}
color="black"
onPress={async () => {
try {
if (!playing) {
await playerObject.loadAsync({
uri: this.state.song.Song_File
});
}
await playerObject.playAsync();
} catch (error) {}
}}
/>
<View style={{ flex: 0.1 }}> </View>
<Ionicons
name="md-pause"
size={40}
color="black"
onPress={async () => {
playing = true;
try {
{
await playerObject.pauseAsync();
}
} catch (error) {}
}}
/>
{/* )} */}
</View>
</Card>
Glad if you can help,