问题:我如何知道从远程源获取音频的操作(例如,使用 加载播放器 player.setUrl(url1, preload: true)
)是否已经为此播放器完成?
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
换句话说,我不想要的是连续调用player.setUrl(url1, preload: true)
两次,获取两次数据。
我正在寻找与player.hasAudio
我上面的示例等效的属性。或另一种获得类似结果的方法。