From bed074d0c9174866bb243a2704ff155e549b0b6c Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Sun, 15 Mar 2020 17:12:16 +0100 Subject: [PATCH] Fix Audioplayer again --- lib/components/audio_player.dart | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/components/audio_player.dart b/lib/components/audio_player.dart index 23d3593..9a30ed5 100644 --- a/lib/components/audio_player.dart +++ b/lib/components/audio_player.dart @@ -63,10 +63,14 @@ class _AudioPlayerState extends State { } _playAction() async { + print("Current mxc: ${AudioPlayer.currentMxc}"); if (AudioPlayer.currentMxc != widget.content.mxc) { if (AudioPlayer.currentMxc != null) { + print("Current mxc is wrong!"); + print("Current audioState: ${flutterSound.audioState}"); if (flutterSound.audioState != t_AUDIO_STATE.IS_STOPPED) { await flutterSound.stopPlayer(); + setState(() => null); } } AudioPlayer.currentMxc = widget.content.mxc; @@ -81,6 +85,7 @@ class _AudioPlayerState extends State { case t_AUDIO_STATE.IS_RECORDING: break; case t_AUDIO_STATE.IS_STOPPED: + print("start Player From Buffer"); await flutterSound.startPlayerFromBuffer( audioFile, codec: t_CODEC.CODEC_AAC, @@ -92,6 +97,7 @@ class _AudioPlayerState extends State { currentPosition = 0; statusText = "00:00"; }); + AudioPlayer.currentMxc = null; } else if (e != null) { DateTime date = DateTime.fromMillisecondsSinceEpoch(e.currentPosition.toInt());