audioplayers
audioplayers copied to clipboard
onPlayerCompletion, onPlayerDurationChanged, onAudioPositionChanged not triggered
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 :)
I have the same issue, The onPlayerState listner stops triggering when the App moves to a new page. @luanpotter Please fix this issue
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));
}
)
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
I can't get the callbacks to work at all on iOS
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
@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?
Closing as stale.