Question: How do I know whether or not the action of fetching the audio from a remote source (e.g. loading a player with player.setUrl(url1, preload: true)
), has already been done for this player?
AudioPlayer player = AudioPlayer();
// Desired:
// `true` if the `load()` action has been completed and that audio is currently
// `loaded` in the player (i.e. it is not necessary to fetch that audio again
// in order to play it)
bool loaded = player.hasAudio; // false
// Once this is awaited, the player now has an audio `loaded`
await player.setUrl(url1, preload: true);
loaded = player.hasAudio; // true
In other words, what I don't want is calling player.setUrl(url1, preload: true)
twice in a row, fetching the data twice.
I am looking for the property that is equivalent to player.hasAudio
in my example above. Or another way to get a similar result.