【发布时间】:2017-11-04 20:30:42
【问题描述】:
我有这个功能,它使用audioplayer plugin 在 Flutter 内部播放声音。
play(int soundFrequency) async {
final result = await audioPlayer.play("urltosound.wav");
}
它工作正常。但现在我希望能够连续播放多个声音。好像我把未来搞砸了。我尝试了这种方法,它非常肮脏和丑陋,但我只是想弄清楚:
playRandomSequence() async {
final result = audioPlayer.play("urltosound.wav").then(play2(pickRandomSoundFrequency()));
}
play2(int soundFrequency) async {
final result = audioPlayer.play("urltosound.wav");
}
基本上,一旦第一个 future 结束,我就用 .then() 方法调用下一个。
我从中得到的是这个错误:
type '_Future' is not a subtype of type '(dynamic) => dynamic' of 'f' where _Future is from dart:async
我该如何解决这个问题?
谢谢
【问题讨论】: