Open couturmi opened 1 year ago
Please take a look at this error flutter: 0:00:05.800000 flutter: 0:00:01.715000 flutter: 0:00:05.800000 flutter: 0:00:01.718000 flutter: 0:00:05.800000 flutter: 0:00:00.000000 <--- the value disappears without completing flutter: 0:00:05.800000 <--- max Duration
Any news on this issue?
@couturmi @codebombi @BrendanBasson4 this appears on which platform?
@couturmi @codebombi @BrendanBasson4 this appears on which platform?
Android 9
@couturmi @codebombi @BrendanBasson4 this appears on which platform?
Also on Android 13
facing same issue on android 11, player is not completing position
Is this reproducible with the assets in the example app? https://github.com/bluefireteam/audioplayers/tree/main/packages/audioplayers/example If not can you provide a file (wrap it as zip, if cannot upload to github)?
Is this reproducible with the assets in the example app?
main
/packages/audioplayers/example If not can you provide a file (wrap it as zip, if cannot upload to github)?
Hi! I tried an aac file in the example app (I changed the url of one of remote audio file) and this is the behaviour. I think there is an issue with aac file.
Looks weird. @mrcsilverfox are you allowed to provide the file any maybe upload it here (wrap in .zip
)?
Finding no solution I made some workaround.
List<int> prevPositions = [0,0];
int lostPositions = 0;
void initPlayer() {
audioPlayer = AudioPlayer();
audioPlayer?.onPositionChanged.listen((Duration duration) {
int positionChanged = duration.inMilliseconds;
logPrint('onPrevPositionChanged:${prevPositions[0]}');
logPrint('onPrevPositionChanged:${prevPositions[1]}');
logPrint('onPositionChanged:$positionChanged');
if(prevPositions[1] > positionChanged){
int diff = prevPositions[1] - prevPositions[0];
int tempNext = prevPositions[1] + diff;
lostPositions += tempNext - positionChanged;
}
///Here is the correct position
int correctPosition = positionChanged+lostPositions;
prevPositions.add(positionChanged);
prevPositions.removeAt(0);
});
}
@RamzanTingku could you help by uploading a public domain sample, while the bug occurs? 😁
same issue here for android 13.0
Bump :) same here on the newest version. @Gustl22 I can share with you a mp3 file causing this problem. kop_03.zip I am using audioplayers 4.1
May needs to be fixed via #1526
I am having this problem on all Android versions I tested. Seems other persons around StackOverflow
are also having trouble with that, as well.
This simple snippet should be enough to ilustrate where exacly the durations are being bugged:
_player.onPositionChanged.listen((Duration newPosition) {
print(newPosition); //after 1 or two seconds the duration resets misteriously.
});
Having the same problem. Any solution ?
I was able to use @RamzanTingku's solution above, and that did temporarily solve the issue where the position resets once during the beginning of the audio track.
But I found an even worse issue that can be reproduced by:
pause()
resume()
When this is done (simply pausing and resuming the audio), the position listener completely loses accuracy.
...
I/flutter (22354): Audio Player Position: 0:00:00.932000 microseconds
I/flutter (22354): Audio Player Position: 0:00:01.134000 microseconds
I/flutter (22354): Audio Player Position: 0:00:01.336000 microseconds
I/flutter (22354): Audio Player Position: 0:00:01.538000 microseconds
I/flutter (22354): Audio Player Position: 0:00:01.741000 microseconds
I/flutter (22354): Audio Player Position: 0:00:01.943000 microseconds
I/flutter (22354): Audio Player Position: 0:00:02.145000 microseconds
I/flutter (22354): Audio Player Position: 0:00:02.347000 microseconds
--- pause() called
--- waited a few seconds
--- resume() called
I/flutter (22354): Audio Player Position: 0:00:02.549000 microseconds
I/flutter (22354): Audio Player Position: 0:00:02.615000 microseconds
I/flutter (22354): Audio Player Position: 0:00:02.817000 microseconds
I/flutter (22354): Audio Player Position: 0:00:08.412000 microseconds <----- Sudden jump by almost 6 seconds?
I/flutter (22354): Audio Player Position: 0:00:08.332000 microseconds <----- Position goes back down?
I/flutter (22354): Audio Player Position: 0:00:08.533000 microseconds <----- Position goes back up?
I/flutter (22354): Audio Player Position: 0:00:08.472000 microseconds <----- ...And continues like this.
I/flutter (22354): Audio Player Position: 0:00:08.410000 microseconds <----- Up and down at random.
I/flutter (22354): Audio Player Position: 0:00:08.348000 microseconds
I/flutter (22354): Audio Player Position: 0:00:08.549000 microseconds
I/flutter (22354): Audio Player Position: 0:00:08.489000 microseconds
I/flutter (22354): Audio Player Position: 0:00:08.383000 microseconds
I/flutter (22354): Audio Player Position: 0:00:08.343000 microseconds
I/flutter (22354): Audio Player Position: 0:00:08.546000 microseconds
I/flutter (22354): Audio Player Position: 0:00:08.462000 microseconds
I/flutter (22354): Audio Player Position: 0:00:08.376000 microseconds
I/flutter (22354): Audio Player Position: 0:00:08.316000 microseconds
I/flutter (22354): Audio Player Position: 0:00:08.472000 microseconds
I/flutter (22354): Audio Player Position: 0:00:08.410000 microseconds
I/flutter (22354): Audio Player Position: 0:00:08.348000 microseconds
I/flutter (22354): Audio Player Position: 0:00:08.284000 microseconds
I/flutter (22354): Audio Player Position: 0:00:08.465000 microseconds
I/flutter (22354): Audio Player Position: 0:00:08.380000 microseconds
I/flutter (22354): Audio Player Position: 0:00:08.294000 microseconds
I/flutter (22354): Audio Player Position: 0:00:08.496000 microseconds
I/flutter (22354): Audio Player Position: 0:00:08.436000 microseconds
I/flutter (22354): Audio Player Position: 0:00:08.357000 microseconds
I/flutter (22354): Audio Player Position: 0:00:08.296000 microseconds
I/flutter (22354): Audio Player Position: 0:00:08.498000 microseconds
I/flutter (22354): Audio Player Position: 0:00:08.437000 microseconds
I/flutter (22354): Audio Player Position: 0:00:08.470000 microseconds <----- Still stuck around 8 seconds
I/flutter (22354): Audio Player Position: 0:00:08.672000 microseconds
I/flutter (22354): Audio Player Position: 0:00:08.875000 microseconds
I/flutter (22354): Audio Player Position: 0:00:09.078000 microseconds <----- Finally increasing again
I/flutter (22354): Audio Player Position: 0:00:09.279000 microseconds
I/flutter (22354): Audio Player Position: 0:00:09.481000 microseconds
I/flutter (22354): Audio Player Position: 0:00:09.682000 microseconds
I/flutter (22354): Audio Player Position: 0:00:09.883000 microseconds
I/flutter (22354): Audio Player Position: 0:00:10.086000 microseconds
I/flutter (22354): Audio Player Position: 0:00:10.289000 microseconds
I/flutter (22354): Audio Player Position: 0:00:10.491000 microseconds
I/flutter (22354): Audio Player Position: 0:00:10.693000 microseconds
I/flutter (22354): Audio Player Position: 0:00:10.894000 microseconds
I/flutter (22354): Audio Player Position: 0:00:11.096000 microseconds
I/flutter (22354): Audio Player Position: 0:00:11.299000 microseconds
So can we not rely on onPositionChanged
at all? It seems even pausing/resuming the audio once breaks the entire thing.
I think this can be only fixed on the native side via #1526 which is currently in the works, but blocked by a flutter issue.
Still no fix ?
Checklist
Current bug behaviour
When using the
onPositionChanged
listener for anAudioPlayer
, it will initially send the correct audio position, but after about 1-2 seconds, the audio position value resets, even though the audio is still playing normally. After the initial reset, the audio position value continues to increase normally, but the actual position is about 1-2 seconds off now.For example, here is the output I am seeing of the
onPositionChanged
values:Expected behaviour
Audio position should increase without resetting.
Steps to reproduce
Environment information
Flutter doctor output