fix AudioPlayer state text

This commit is contained in:
Christian Pauly 2021-05-01 15:45:48 +02:00
parent 16febd3c34
commit f3b0092bf0

View File

@ -124,7 +124,11 @@ class _AudioPlayerState extends State<AudioPlayerWidget> {
default: default:
onAudioPositionChanged ??= onAudioPositionChanged ??=
audioPlayer.onAudioPositionChanged.listen((state) { audioPlayer.onAudioPositionChanged.listen((state) {
setState(() => currentPosition = state.inMilliseconds.toDouble()); setState(() {
statusText =
'${state.inMinutes.toString().padLeft(2, '0')}:${(state.inSeconds % 60).toString().padLeft(2, '0')}';
currentPosition = state.inMilliseconds.toDouble();
});
}); });
onDurationChanged ??= audioPlayer.onDurationChanged.listen((max) => onDurationChanged ??= audioPlayer.onDurationChanged.listen((max) =>
setState(() => maxPosition = max.inMilliseconds.toDouble())); setState(() => maxPosition = max.inMilliseconds.toDouble()));