audioplayers icon indicating copy to clipboard operation
audioplayers copied to clipboard

In audioPlayer.onPlayerComplete event listener, player.state is still playing state

Open jzz567 opened this issue 3 years ago • 8 comments

Checklist

  • [x] I read the troubleshooting guide before raising this issue
  • [x] I made sure that the issue I am raising doesn't already exist

Current bug behaviour

When a LOCAL audio file play finished, audioPlayer.onPlayerComplete is triggered, but in this event listener, player state is still in playing state. Also if I have a button, user can click it to get the audio player state, after LOCAL audio file play finished, user click button, the audio player.state is also in playing state.

Expected behaviour

In audioPlayer.onPlayerComplete listener, player.state is complete After audio file play finished, player.state is complete

Steps to reproduce

  1. Add onPlayerComplete listener
  2. print player.state in onPlayerComplete listener
  3. print output is playing state
audioPlayer.onPlayerComplete.listen(() {
print(audioPlayer.state == PlayerState.playing);// true
}
<Button onPress()=>{
print(audioPlayer.state == PlayerState.playing);}>click</Button>
// after audio file play finished, click button will output true

Environment information

  • audioplayers version: 1.0.1

Platform:

  • OS name and version: android 10
  • Device: android emulator
  • build mode: debug
  • error peculiarities (optional):

jzz567 avatar Aug 13 '22 04:08 jzz567

Same problem detected for my app. Seems to be a regression because I used the plugin since start of 2022 and It was working perfectly.

When the the audio file is playing and auto complete/end the playerState is not triggering ' completed ' state. Same for 'stopped'. Whereas 'pause' is still working.

thanks!

Nico3652 avatar Aug 26 '22 14:08 Nico3652

I have the same issue. I've updated to audioplayers: ^1.0.1 and the state is always playing even though it finished playing. In 0.20.1 it worked for me. Happens on both iOS and Android.

When a LOCAL audio file play finished

Just a note. For me, it's UrlSource that has the issue. I guess it's not connected with source implementation.

itsJoKr avatar Aug 27 '22 18:08 itsJoKr

Seeing the same behavior as mentioned above in my app with the audioplayers: ^1.0.1

Tom3652 avatar Aug 28 '22 13:08 Tom3652

Hey, guys. I might have a fix, it's here: https://github.com/bluefireteam/audioplayers/pull/1257

And you can test it before release. If you do, please tell me if it worked for you:

~~audioplayers:~~ ~~git:~~ ~~url: https://github.com/itsJoKr/audioplayers.git~~ ~~path: packages/audioplayers~~ ~~ref: 0afb518e38f23717d0628ab89a72c08aaf6ce097~~

itsJoKr avatar Aug 28 '22 17:08 itsJoKr

Hey @itsJoKr , thanks for working on it ! I have tried your version and i see the same behavior unfortunately, it doesn't call any other event than PlayerState.playing :/

Tom3652 avatar Aug 28 '22 17:08 Tom3652

@Tom3652 Ah, I think I have one bug that happens in your use case, can you try this one:

  audioplayers:
    git:
      url: https://github.com/itsJoKr/audioplayers.git
      path: packages/audioplayers
      ref: f82378f476dcf5a597ef02ba1ed7294eb3a65f7d

itsJoKr avatar Aug 28 '22 18:08 itsJoKr

Thank you very much i confirm this is working fine with the above git reference ! :)

Tom3652 avatar Aug 28 '22 19:08 Tom3652

@Tom3652 Ah, I think I have one bug that happens in your use case, can you try this one:

  audioplayers:
    git:
      url: https://github.com/itsJoKr/audioplayers.git
      path: packages/audioplayers
      ref: f82378f476dcf5a597ef02ba1ed7294eb3a65f7d

Thanks a lot this is working fine :D

pbaudri avatar Sep 20 '22 11:09 pbaudri

I'm using v5.2.0 and I'm still seeing this happen.

I added a listener for onPlayerComplete and it's not being picked up on Android (14). It is working on macOS, Linux, and iOS.

define-private-public avatar Oct 16 '23 05:10 define-private-public

@define-private-public can you open a new issue and fill ALL the fields in order to determine the cause.

The above issue has been resolved already.

Gustl22 avatar Oct 16 '23 06:10 Gustl22