bluefireteam / audioplayers

A Flutter package to play multiple audio files simultaneously (Android/iOS/web/Linux/Windows/macOS)
https://pub.dartlang.org/packages/audioplayers
MIT License
2.01k stars 844 forks source link

Bluetooth controls don't trigger onPlayerStateChanged event on IOS #476

Open ozz-rjq opened 4 years ago

ozz-rjq commented 4 years ago

Basically, I have in-app play/pause controls, which I'd like to animate using animated button in a stateful widget once player's state is changed.

Widget code:

audioPlayer.onPlayerStateChanged?.listen((state) {
      if (state == AudioPlayerState.PLAYING) {
        _controller.forward();
      } else if ((state == AudioPlayerState.PAUSED)) {
        _controller.reverse();
}

Everything works great except the bluetooth controls on ios. For example, when I pause the remote audio by headphone controls, seems like it doesn't trigger onPlayerStateChanged and the in-app controls stay the same (but the actual audio is paused). Is it possible to intecept that events?

Ceschref commented 3 years ago

I have same issue with the headphone. when I unplug my headphone from the phone. trigger onPlayerStateChange doesn't work and I can't catch event change State to switch icon pause and play. pls fix this!