Fix Audioplayer again
This commit is contained in:
parent
348884fc7e
commit
bed074d0c9
|
@ -63,10 +63,14 @@ class _AudioPlayerState extends State<AudioPlayer> {
|
||||||
}
|
}
|
||||||
|
|
||||||
_playAction() async {
|
_playAction() async {
|
||||||
|
print("Current mxc: ${AudioPlayer.currentMxc}");
|
||||||
if (AudioPlayer.currentMxc != widget.content.mxc) {
|
if (AudioPlayer.currentMxc != widget.content.mxc) {
|
||||||
if (AudioPlayer.currentMxc != null) {
|
if (AudioPlayer.currentMxc != null) {
|
||||||
|
print("Current mxc is wrong!");
|
||||||
|
print("Current audioState: ${flutterSound.audioState}");
|
||||||
if (flutterSound.audioState != t_AUDIO_STATE.IS_STOPPED) {
|
if (flutterSound.audioState != t_AUDIO_STATE.IS_STOPPED) {
|
||||||
await flutterSound.stopPlayer();
|
await flutterSound.stopPlayer();
|
||||||
|
setState(() => null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AudioPlayer.currentMxc = widget.content.mxc;
|
AudioPlayer.currentMxc = widget.content.mxc;
|
||||||
|
@ -81,6 +85,7 @@ class _AudioPlayerState extends State<AudioPlayer> {
|
||||||
case t_AUDIO_STATE.IS_RECORDING:
|
case t_AUDIO_STATE.IS_RECORDING:
|
||||||
break;
|
break;
|
||||||
case t_AUDIO_STATE.IS_STOPPED:
|
case t_AUDIO_STATE.IS_STOPPED:
|
||||||
|
print("start Player From Buffer");
|
||||||
await flutterSound.startPlayerFromBuffer(
|
await flutterSound.startPlayerFromBuffer(
|
||||||
audioFile,
|
audioFile,
|
||||||
codec: t_CODEC.CODEC_AAC,
|
codec: t_CODEC.CODEC_AAC,
|
||||||
|
@ -92,6 +97,7 @@ class _AudioPlayerState extends State<AudioPlayer> {
|
||||||
currentPosition = 0;
|
currentPosition = 0;
|
||||||
statusText = "00:00";
|
statusText = "00:00";
|
||||||
});
|
});
|
||||||
|
AudioPlayer.currentMxc = null;
|
||||||
} else if (e != null) {
|
} else if (e != null) {
|
||||||
DateTime date =
|
DateTime date =
|
||||||
DateTime.fromMillisecondsSinceEpoch(e.currentPosition.toInt());
|
DateTime.fromMillisecondsSinceEpoch(e.currentPosition.toInt());
|
||||||
|
|
Loading…
Reference in a new issue