audioplayers icon indicating copy to clipboard operation
audioplayers copied to clipboard

onPlayerCompletion, onPlayerDurationChanged, onAudioPositionChanged not triggered

Open flippy16 opened this issue 4 years ago • 6 comments

Hy Guys, I've tried to use this onPlayerCompletion, onPlayerDurationChanged, and onAudioPositionChanged, but none of them is triggered, but when i use onPlayerStateChanged it's worked whenever i tap on stop and play button,

audioPlayer.onDurationChanged.listen((data) { print(data.inSeconds); }); audioPlayer.onPlayerStateChanged.listen((data) { print(data.toString()); }); audioPlayer.onPlayerCompletion.listen((data) { _stopAudio(); });

this is my code, I tried to put it on initState() and doesn't work, i move it to my _playAudio function also doesn't work. Can anyone help me please, solution or explanation maybe

Thank you :)

flippy16 avatar Apr 23 '20 12:04 flippy16

I have the same issue, The onPlayerState listner stops triggering when the App moves to a new page. @luanpotter Please fix this issue

athul-ain avatar Apr 24 '20 10:04 athul-ain

Finally, I got a solution. Using these listeners in a Stream Builder will fix the issue

StreamBuilder(
 stream: audioPlayer.onAudioPositionChanged,
 builder: (context, snapshot){
 if(!asyncSnapshot.hasData) return Text("");
 else return Text(parseToMinutesSeconds(snapshot.data.inMilliseconds));
 }
)

athul-ain avatar May 02 '20 03:05 athul-ain

But Still, onPlayerCompletion is not working,

V/MediaPlayer(16179): resetDrmState: mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false V/MediaPlayer(16179): cleanDrmObj: mDrmObj=null mDrmSessionId=null V/MediaPlayer(16179): resetDrmState: mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false V/MediaPlayer(16179): cleanDrmObj: mDrmObj=null mDrmSessionId=null

athul-ain avatar May 02 '20 06:05 athul-ain

I can't get the callbacks to work at all on iOS

tamoyal avatar May 14 '21 15:05 tamoyal

I think what's happening is after you release a player, you can still play the audio but none of the callbacks are called, even if you reset them

tamoyal avatar May 14 '21 15:05 tamoyal

@flippy16 @athul-ain @tamoyal can you check, is this still a thing with 1.x.x? Thx :) Also can you provide a more detailed example or reproducable project? Does this occur on all platforms?

Gustl22 avatar Sep 03 '22 09:09 Gustl22

Closing as stale.

Gustl22 avatar Nov 03 '22 08:11 Gustl22