我正在构建我的第一个Flutter应用,并且试图对音频进行精细控制。
我已经弄清楚了如何进行播放,暂停和停止功能,现在我想弄清楚如何跳过15秒或返回15秒,而我所做的一切都会破坏应用程序或不起作用
bool _isPlaying = false;
bool _isPaused = false;
FlutterSound _sound = FlutterSound();
double _playPosition;
Stream<PlayStatus> _playerSubscription;
void initState() {
super.initState();
_sound = FlutterSound();
_playPosition = 0;
}
void _stop() async {
await _sound.stopPlayer();
setState(() => _isPlaying = false);
}
void _play() async {
await _sound.startPlayer(widget.snapshot.data["audio"]);
_playerSubscription = _sound.onPlayerStateChanged
..listen((e) {
if (e != null) {
setState(() => _playPosition = e.currentPosition/ e.duration);
}
});
setState(() => _isPlaying = true);
}
void _pause() async{
await _sound.pausePlayer();
setState(() {
_isPaused = true;
_isPlaying = false;
});
}
void _resume() async{
await _sound.resumePlayer();
setState(() {
_isPaused = false;
_isPlaying = true;
});
}
void fastForward() async{
setState(() => _playPosition);
}
void rewind(){}
我希望使用这些功能在15秒之前跳过音频并在15秒之前返回