From 348884fc7eddd3f2ef42e685ef2264b5fbd5d0a9 Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Sun, 15 Mar 2020 14:15:45 +0100 Subject: [PATCH] Fix audioplayer --- lib/components/audio_player.dart | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/components/audio_player.dart b/lib/components/audio_player.dart index 946f273..23d3593 100644 --- a/lib/components/audio_player.dart +++ b/lib/components/audio_player.dart @@ -14,6 +14,8 @@ class AudioPlayer extends StatefulWidget { final Color color; final MxContent content; + static String currentMxc; + const AudioPlayer(this.content, {this.color = Colors.black, Key key}) : super(key: key); @@ -37,8 +39,6 @@ class _AudioPlayerState extends State { double currentPosition = 0; double maxPosition = 0; - static String currentMxc; - @override void dispose() { if (flutterSound.audioState == t_AUDIO_STATE.IS_PLAYING) { @@ -63,13 +63,13 @@ class _AudioPlayerState extends State { } _playAction() async { - if (currentMxc != widget.content.mxc) { - if (currentMxc != null) { + if (AudioPlayer.currentMxc != widget.content.mxc) { + if (AudioPlayer.currentMxc != null) { if (flutterSound.audioState != t_AUDIO_STATE.IS_STOPPED) { await flutterSound.stopPlayer(); } - currentMxc = widget.content.mxc; } + AudioPlayer.currentMxc = widget.content.mxc; } switch (flutterSound.audioState) { case t_AUDIO_STATE.IS_PLAYING: @@ -86,7 +86,7 @@ class _AudioPlayerState extends State { codec: t_CODEC.CODEC_AAC, ); soundSubscription ??= flutterSound.onPlayerStateChanged.listen((e) { - if (currentMxc != widget.content.mxc) { + if (AudioPlayer.currentMxc != widget.content.mxc) { soundSubscription?.cancel()?.then((f) => soundSubscription = null); this.setState(() { currentPosition = 0;