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
Which API doesn't behave as documented, and how does it misbehave?
Refer to the following piece of code for android,
AudioService.playbackStateStream.listen((event) {
var position = event.currentPosition;
print((position?.inSeconds?.toString()) ?? '0.0');
});
What happens is that the position is updated as audio is playing(I am using just_audio), but after a few seconds, it stops printing the current position, like it could print 1,2,3,4 then maybe at around 8 it stops printing, but all this while the audio is playing. But what is weird is when u put the device in lock, then unlock it, or when u minimize the application and then reopen it, it will immediately print the time... For example, at first it would print 0,1,2,3,4,5, then maybe stop at 9, and hang there without printing anything, now when i minimize the app and then open it again, it will print 32 (Meaning the currentposition changes were just not being added to the stream). However again after some time, it will pause, then when you do the above, it continues...and so on.
Expected behavior
I expected that, it keeps printing the current position time without pausing and resuming after the triggers mentioned above
Runtime Environment (please complete the following information if relevant):
Device: [e.g. TECNO AB7]
OS: [e.g. Android 9.0.0]
Flutter SDK version
[√] Flutter (Channel stable, v1.17.5, on Microsoft Windows [Version 10.0.18363.900], locale en-UG)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.1)
[√] Android Studio (version 3.4)
[√] VS Code (version 1.46.1)
[√] Connected device (1 available)
• No issues found!
The text was updated successfully, but these errors were encountered:
From what you've described, everything appears to be behaving exactly as documented.
AudioService.playbackStateStream emits exactly those events that you yourself have broadcast via AudioServiceBackground.setState which says on its documentation page:
/// The playback [position] should be explicitly updated only when the normal
/// continuity of time is disrupted, such as when the user performs a seek,
/// or buffering occurs, etc. Thus, the [position] parameter indicates the
/// playback position at the time the state was updated while the
/// [updateTime] parameter indicates the precise time of that update.
PlaybackState.currentPosition is a convenience method that computes where the current position would be based on the last update time and position (adding to it the amount of time that has elapsed since the last update time), but this is NOT a stream, so it will not emit continuous values. It is just a plain old value that you need to query repeatedly to see it change. Although you may if you wish create a stream that queries this value periodically. Only, that is not the purpose of the playbackStateStream which only reports state changes emitted through setState.
If you still think this is not behaving as per the documentation, I will need you to complete the bug report fully, including a minimal reproduction project, and contrast the behaviour you're observing with what the documentation says should happen.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs, or use StackOverflow if you need help with audio_service.
Which API doesn't behave as documented, and how does it misbehave?
Refer to the following piece of code for android,
What happens is that the position is updated as audio is playing(I am using just_audio), but after a few seconds, it stops printing the current position, like it could print 1,2,3,4 then maybe at around 8 it stops printing, but all this while the audio is playing. But what is weird is when u put the device in lock, then unlock it, or when u minimize the application and then reopen it, it will immediately print the time... For example, at first it would print 0,1,2,3,4,5, then maybe stop at 9, and hang there without printing anything, now when i minimize the app and then open it again, it will print 32 (Meaning the currentposition changes were just not being added to the stream). However again after some time, it will pause, then when you do the above, it continues...and so on.
Expected behavior
I expected that, it keeps printing the current position time without pausing and resuming after the triggers mentioned above
Runtime Environment (please complete the following information if relevant):
Flutter SDK version
The text was updated successfully, but these errors were encountered: