In my app I allow the users to choose the duration of sounds : 5 min / 10 min .... until the original duration. When I set the duration to Trackplayer.add()
and call getActiveTrack().duration
the logs display the right duration choosen by the user. However in background mode on Ios this is the original duration that is displayed. Same when I call useProgression()
to verify the duration. And there is only one track in the queue.
Here are a couple of screenshots, as you can see the title is the good one but not the duration.
Here is my code
await TrackPlayer.add({
type: TrackType.HLS,
url: media.video,
title: media.title,
artwork: imageUrl,
artist: 'John Doe',
duration: totalDuration / 1000, // 300 seconds
});
I have even tried to update the track metadata
await TrackPlayer.updateMetadataForTrack(0, {
...
duration: totalDuration / 1000,
});
Then when I get the current track
const duration = (await TrackPlayer.getActiveTrack()).duration;
console.log(duration); // Output 300
Any idea how to achieve this ?
react-native-track-player versions tested : 3.2.0 and 4.0.0-rc04