You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thank you for the detailed report! Currently we have a lot going on. I try to fix it eventually. Feel free to post a merge request, if you can provide a fix :D
I found a workaround for this! (I'm on Ubuntu 22.04. can provide more details if needed)
This is the controller class I'm using for the audioplayer.
classController{
AudioPlayer audioPlayer =AudioPlayer();
ValueNotifier<int> sliderNotifier =ValueNotifier<int>(0); //ValueNotifier so no need for setStateValueNotifier<bool> playingNotifier =ValueNotifier<bool>(false); //ValueNotifier so no need for setStateController() {
audioPlayer.onPositionChanged.listen((Duration event){
sliderNotifier.value = event.inMilliseconds; //can be set to seconds, I like it to be set to as small of a unit as possible
});
audioPlayer.onPlayerStateChanged.listen((PlayerState state) {
playingNotifier.value = state ==PlayerState.playing;
});
}
Future<void> playSong() async {
if (playingNotifier.value){
print("pause");
await audioPlayer.pause();
playingNotifier.value =false;
}
else{
print("resume");
//await audioPlayer.resume();// CHANGE TO:await audioPlayer.play(DeviceFileSource(...), position:Duration(milliseconds: sliderNotifier.value)); // this gives the same result as audioPlayer.resume()
playingNotifier.value =true;
}
}
}
I can provide further snippets of my code if necessary. I tried looking into the issue, but really can't find the thing that's causing the delay. This can be used as a workaround in the meantime.
calcitem
added a commit
to calcitem/Sanmill
that referenced
this issue
Nov 30, 2024
Checklist
Current bug behaviour
There's a significant and somewhat random delay that occurs when playing local files if time passes between setSource() and resume().
During the delay the player state reports playing, and multiple position events are fired with position at 0:00:0000.
Eventually the file plays, and the position events continue with accurate time info.
If the file is played very quickly after setting the source the file the sound plays immediately (similar to using the play() shortcut).
Expected behaviour
The file should play immediately when calling resume().
Steps to reproduce
Run the code sample:
Compare with INSTA-PLAY button.
Code sample
Full Code Sample
Affected platforms
Linux
Platform details
Debian 12
AudioPlayers Version
5.2.1
Build mode
debug
Logs
Full Logs
Flutter doctor:
Related issues / more information
No response
Working on PR
no way
The text was updated successfully, but these errors were encountered: