我能够在按钮的 onPressed() 方法中成功播放本地音频文件,但是再次按下时,文件一旦完成就不会再次播放。使用音频播放器库。
播放音频文件的方法
playLocal(var audioPath) async {
AudioPlayer.logEnabled = true;
await audioCache.play('broke.mov');
}
正在使用 onPressed() 方法
child: FloatingActionButton.extended(
label: Text("ye"),
backgroundColor: gapBlue,
onPressed: () {
playLocal('');
if (isSwitched) {
print("isSwitched $isSwitched");
} else
print("isSwitched $isSwitched");
},
),