Файл: DataList. json
[
{
"id": "abcd-001",
"title": "Push Ups",
"image": "imageOne",
"description": "There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. ",
"duration": 10,
"sets": "",
"url" : "../assets/track1.mp3"
"break": 40
},
{
"id": "abcd-002",
"title": "Pull Ups",
"image": "imageTwo",
"description": "There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. ",
"duration": 30,
"sets": "",
"url" : "../assets/track2.mp3"
"break": 40
},
]
Компонент : Трек. js
useEffect(() => {
TrackPlayer.setupPlayer();
TrackPlayer.updateOptions({
stopWithApp: true,
capabilities: [
TrackPlayer.CAPABILITY_PLAY,
TrackPlayer.CAPABILITY_PAUSE,
TrackPlayer.CAPABILITY_STOP,
TrackPlayer.CAPABILITY_SKIP_TO_NEXT,
],
compactCapabilities: [
TrackPlayer.CAPABILITY_PLAY,
TrackPlayer.CAPABILITY_PAUSE,
],
});
}, []);
const togglePlayBack = async () => {
await TrackPlayer.add({
title: title,
id: id,
url: require('../assets/audio/track1.mp3'),
artist: 'Imran Sayed',
duration: duration,
});
};
<TouchableOpacity style={styles.main}>
<View style={styles.imgContainer}>
<Image source={Images[`${image}`]} style={styles.image} />
</View>
<View style={styles.info}>
<Text style={styles.text}> {title} </Text>
<Text style={styles.description}> {description} </Text>
<Text style={styles.duration}> Duration - {duration} </Text>
<Button
color="darkslateblue"
title="Start"
onPress={togglePlayBack}
/>
</View>
</TouchableOpacity>
Я не могу найти способ приостановить музыку c, когда продолжительность музыки c равна продолжительности трека в DataList. json.
Музыка c должна быть приостановлено и должно быть возобновлено после указанной продолжительности. Любая помощь будет оценена!