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
I made sure that the issue I am raising doesn't already exist
Current bug behaviour
TL;DR
On Android, when both AudioPlayer.setPlayerMode(PlayerMode.lowLatency) and AudioPlayer.setReleaseMode(ReleaseMode.stop) are used for the same player, the sound is played only the first time. Please see the attached application.
Context: I have a simple app that prepares 2 players, with a different, very short sound (from assets) each, and it keeps them around and uses them whenever one of the sounds should be played, ideally with as little delay as possible. It is impossible for the same sound to overlap, but there can be an overlap between the two sounds, hence 2 players.
I want to use low latency on Android, but at the same time, I want to be able to play a sound with just AudioPlayer.resume() using the pre-initialized players. This seems not to work together - the sound is only played the first time. I suppose the reason is that low latency disables all streams, and the streams are necessary for the player to get the playback completion signal using onComplete, and reset the sound (otherwise the sound is at its end and resuming playback immediately finishes).
As a result, it seems to be impossible to do what I want. One option is to disable low latency (which would defeat its purpose), or use low latency, but then create a new player each time a sound should be played, introducing latency due to initialization (AudioPlayer.setSourceAsset and others are async calls that go through the whole MethodChannel magic).
I hope that you find my mistake in the snippet, or in my thinking, and come up with a working solution. But it is possible that this is the desired (or only possible) behavior, in which case I think documentation is lacking - e.g. here (https://github.com/bluefireteam/audioplayers/blob/main/getting_started.md?plain=1#L166) it mentions what gets disabled, and it doesn't mention the completion signal. If this bug gets classified as invalid, the docs could/should be updated.
Expected behaviour
I expect the same AudioPlayer instance to play the sound each time, with low latency.
Steps to reproduce
Run the snippet as you usually would. You will need to add a sound as assets/audio/short_sound.mp3, I link below to the one I'm using.
You have to call stop before calling resume as in LowLatency mode, the player doesn't know when the sound finished, further there is no onComplete event available. So the user needs to stop the player, before be able to resume again.
# Description
Improve the documentation for:
- Getting started:
- Fix typos from #1678
- Call stop in low latency, missing completion event (#1489)
- Set prefix for AssetSource via AudioCache (#1620, #1639)
- Troubleshooting guide:
- Verify audio format, e.g. with Aconvert
- Change heading size of web-cors-policy
- Example:
- README: How to setup example with `melos`, tab descriptions
- example.md: Add Simple (one-page) Example for pub.dev, see
https://dart.dev/tools/pub/package-layout#examples (#1616)
- Showcase for using play in `addPostFrameCallback`
Closes#1650
Co-authored-by: Lukas Klingsbo <[email protected]>
Checklist
Current bug behaviour
TL;DR
On Android, when both
AudioPlayer.setPlayerMode(PlayerMode.lowLatency)
andAudioPlayer.setReleaseMode(ReleaseMode.stop)
are used for the same player, the sound is played only the first time. Please see the attached application.Context: I have a simple app that prepares 2 players, with a different, very short sound (from assets) each, and it keeps them around and uses them whenever one of the sounds should be played, ideally with as little delay as possible. It is impossible for the same sound to overlap, but there can be an overlap between the two sounds, hence 2 players.
I want to use low latency on Android, but at the same time, I want to be able to play a sound with just
AudioPlayer.resume()
using the pre-initialized players. This seems not to work together - the sound is only played the first time. I suppose the reason is that low latency disables all streams, and the streams are necessary for the player to get the playback completion signal usingonComplete
, and reset the sound (otherwise the sound is at its end and resuming playback immediately finishes).As a result, it seems to be impossible to do what I want. One option is to disable low latency (which would defeat its purpose), or use low latency, but then create a new player each time a sound should be played, introducing latency due to initialization (
AudioPlayer.setSourceAsset
and others areasync
calls that go through the wholeMethodChannel
magic).I hope that you find my mistake in the snippet, or in my thinking, and come up with a working solution. But it is possible that this is the desired (or only possible) behavior, in which case I think documentation is lacking - e.g. here (https://github.com/bluefireteam/audioplayers/blob/main/getting_started.md?plain=1#L166) it mentions what gets disabled, and it doesn't mention the completion signal. If this bug gets classified as invalid, the docs could/should be updated.
Expected behaviour
I expect the same
AudioPlayer
instance to play the sound each time, with low latency.Steps to reproduce
Run the snippet as you usually would. You will need to add a sound as
assets/audio/short_sound.mp3
, I link below to the one I'm using.Code sample
Code sample
Affected platforms
Android
Platform details
Android 13, Pixel 7 Pro
The setting, according to the docs, is only relevant to Anroid.
AudioPlayers Version
4.0.1
Build mode
debug, release
Audio Files/URLs/Sources
https://www.zedge.net/ringtone/99a9a13c-2881-32ff-aa8b-84302fb3532c
Screenshots
No response
Logs
There are no relevant logs.
Related issues / more information
No response
Working on PR
no way
The text was updated successfully, but these errors were encountered: