rxlabz / audioplayer

A flutter plugin to play audio files iOS / Android / MacOS / Web ( Swift/Java )

Home Page:https://pub.dartlang.org/packages/audioplayer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failed assertion: line 81 pos 16: '_state == AudioPlayerState.PLAYING': is not true

DevilWarrior opened this issue · comments

Hi,

I'm building a messaging app and I'm getting the error on the title line when playing a local file. I'm calling the audioPlayer.play() withing the message element. Since there are a lot of them I'm building the AudioPlayer object when tapping on an audio message and than trying to dispose it afterwards. In doing so the audio does play but the app crashes right afterwards with the error mentioned above. Any help is greatly appreciated.

# Here I initialized the AudioPlayer
audioPlayer = new AudioPlayer();

# Here I play the audio file, it crashes here 
await audioPlayer.play(_audioPath, isLocal: true);
setState(() => playerState = PlayerState.playing);

Hi,
I'm not sure you need to await and also you don't absolutely have to specify whether the file is local or not.

Maybe you should look at the code samples again and the example project.

The example does use await. And there's a method for _playLocal hence why I used it.

  Future play() async {
    await audioPlayer.play(kUrl);
    setState(() {
      playerState = PlayerState.playing;
    });
  }

  Future _playLocal() async {
    await audioPlayer.play(localFilePath, isLocal: true);
    setState(() => playerState = PlayerState.playing);
  }

This is still an issue. Do you know what it indicates, @eddywm?

I believe the issue got solved but I can't quite remember now how. Will close this unless you think otherwise.

It's still an issue for me. I can't diagnose it because everything in our code seems to be just fine

Sorry, I just realized your previous comment was sent a separate user, re-opening in case someone else want to comment on this.