audioplayers
audioplayers copied to clipboard
Does not play with asset source and lowLatency mode (BUG)
Low Latency mode does not work on Android
Full Description
Using sound player with AssetSource and lowLatency mode does not work. No sound is played. No error either, it just doesn't do anything.
Code to Reproduce
await _soundPlayer.play(
AssetSource('sounds/long_beep.mp3'),
mode: PlayerMode.lowLatency,
);
Log Errors No errors, just does not play sound
Files/URLs/Sources N/A
Screenshots N/A
Platforms Android
- OS: android
- OS version: android version 11 on physical device. Also emulator Pixel 4 API 31 Android 12
- Device: Samsung Galaxy A20
- flutter version: 3.0.2
- audioplayers version: 1.0.1
- release or not release: debug mode
- does the error occur and does it have any peculiarities: easy to reproduce
** workaround**
Commenting out PlayerMode resolves the issue.
Plz use issue template! Also which platform you running the app? See also the parity table
Plz use issue template! Also which platform you running the app? See also the parity table
I have provided more info using bug form. This is on Android.
Same issue with me
This problem also exists for me In the real Android phone and emulator
Same, lowlatency just does not work. On real device and emulator.
Same issue on Android 10
Looks like the same issue as #1176 !
Hi I am only getting it on pixel 4 emulator. Works fine on pixel 5. Also I do get an error, other user is not getting an error, just no sound. D
From: @.> Sent: Monday, July 4, 2022 10:53 PM To: @.> Cc: @.>; @.> Subject: Re: [bluefireteam/audioplayers] Does not play with asset source and lowLatency mode (BUG) (Issue #1193)
Looks like the same issue as #1176https://github.com/bluefireteam/audioplayers/issues/1176 !
— Reply to this email directly, view it on GitHubhttps://github.com/bluefireteam/audioplayers/issues/1193#issuecomment-1173672295, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AA5N3HX6Y3C5K67U3OL7KYDVSK7BDANCNFSM5Z2FYE3A. You are receiving this because you authored the thread.Message ID: @.***>
has anyone found a solution to this issue?
has anyone found a solution to this issue?
As a workaround you can remove the low latency mode. Hopefully it will get fixed one day
As a workaround you can remove the low latency mode. Hopefully it will get fixed one day
As I am working on a percussion based system I need my sounds to overlay one another. Removing the low latency mode gives me lots of delays :( yeah hopefully we get an update soon
@Gustl22 are you going to consider fixing this issue or not? Not much activity since your comment that the proper form should be used, which I have done...
same .
@under3415 I currently working on some tests which touches all implementations of the various platforms, and will also include tests for lowLatency at some point. As this feature is only available on Android, this has not high priority for me personally. I eventually have time to fix it, when coming to this point, but you or someone else may have an attempt to fix it by themselves and create a Pull-Request, it's easier than you might think. That's the good thing with open source, if something bothers you, you can fix it, but someone has to invest their spare time :)
Can we get a new release on pub.dev with this fix ?
yes please. Can we have an update release? I need this to be fixed desperately:(
We still have some open Merge Requests which include fixes.
In the mean time you can override your dependencies in pubspec.yaml, e.g.:
dependency_overrides:
audioplayers:
git:
url: https://github.com/bluefireteam/audioplayers.git
path: 'packages/audioplayers'
audioplayers_platform_interface:
git:
url: https://github.com/bluefireteam/audioplayers.git
path: 'packages/audioplayers_platform_interface'
audioplayers_android:
git:
url: https://github.com/bluefireteam/audioplayers.git
path: 'packages/audioplayers_android'
After overriding it doesnt seemed to work for me.
In my pubspec.yaml:
dependencies: flutter: sdk: flutter
audioplayers: ^1.0.1
dependency_overrides: audioplayers: git: url: https://github.com/bluefireteam/audioplayers.git path: 'packages/audioplayers' audioplayers_platform_interface: git: url: https://github.com/bluefireteam/audioplayers.git path: 'packages/audioplayers_platform_interface' audioplayers_android: git: url: https://github.com/bluefireteam/audioplayers.git path: 'packages/audioplayers_android'
The play audio function that i called:
static void play(MY_SAMPLE sample) => _player.play(AssetSource(samples[sample]! + _ext), mode: PlayerMode.lowLatency);
Same issue, no sound after adding the PlayMode.lowLatency. May I know if I did something wrong here?
@leongkeng I noticed you can play a file in lowLatency, but not reusing the player, or play a sample twice. There still seems to be something off. Let's track this in #1176
@leongkeng can you test again with current main? Don't forget to delete pub git cache or add ref to overridden dependencies in order to get the latest changes.
@leongkeng can you test again with current
main? Don't forget to delete pub git cache or addrefto overridden dependencies in order to get the latest changes.
I did 'flutter clean' and 'flutter pub cache repair', then flutter pub get. Also I did overriding my dependencies following your previous comments but still did not work. I managed to play one sound then it stops playing, its the same issue.
this is my console output after i tried to play a second audio
D/CCodec (25605): allocate(c2.android.raw.decoder) I/CCodec (25605): Created component [c2.android.raw.decoder] D/CCodecConfig(25605): read media type: audio/raw D/ReflectedParamUpdater(25605): extent() != 1 for single value type: algo.buffers.max-count.values D/ReflectedParamUpdater(25605): extent() != 1 for single value type: output.subscribed-indices.values D/ReflectedParamUpdater(25605): extent() != 1 for single value type: input.buffers.allocator-ids.values D/ReflectedParamUpdater(25605): extent() != 1 for single value type: output.buffers.allocator-ids.values D/ReflectedParamUpdater(25605): extent() != 1 for single value type: algo.buffers.allocator-ids.values D/ReflectedParamUpdater(25605): extent() != 1 for single value type: output.buffers.pool-ids.values D/ReflectedParamUpdater(25605): extent() != 1 for single value type: algo.buffers.pool-ids.values I/CCodecConfig(25605): query failed after returning 8 values (BAD_INDEX) D/CCodecConfig(25605): c2 config diff is Dict { D/CCodecConfig(25605): c2::u32 coded.bitrate.value = 64000 D/CCodecConfig(25605): c2::u32 input.buffers.max-size.value = 65536 D/CCodecConfig(25605): c2::u32 input.delay.value = 0 D/CCodecConfig(25605): string input.media-type.value = "audio/raw" D/CCodecConfig(25605): string output.media-type.value = "audio/raw" D/CCodecConfig(25605): c2::u32 raw.channel-count.value = 2 D/CCodecConfig(25605): c2::u32 raw.pcm-encoding.value = 0 D/CCodecConfig(25605): c2::u32 raw.sample-rate.value = 44100 D/CCodecConfig(25605): } D/CCodec (25605): [c2.android.raw.decoder] buffers are bound to CCodec for this session D/CCodecConfig(25605): no c2 equivalents for durationUs D/CCodecConfig(25605): no c2 equivalents for track-id D/CCodecConfig(25605): no c2 equivalents for bits-per-sample D/CCodecConfig(25605): no c2 equivalents for channel-mask D/CCodecConfig(25605): no c2 equivalents for flags D/CCodecConfig(25605): c2 config diff is c2::u32 raw.channel-count.value = 1 W/Codec2Client(25605): query -- param skipped: index = 1107298332. D/CCodec (25605): setup formats input: AMessage(what = 0x00000000) = { D/CCodec (25605): int32_t channel-count = 1 D/CCodec (25605): int32_t max-input-size = 65536 D/CCodec (25605): string mime = "audio/raw" D/CCodec (25605): int32_t pcm-encoding = 2 D/CCodec (25605): int32_t sample-rate = 44100 D/CCodec (25605): } and output: AMessage(what = 0x00000000) = { D/CCodec (25605): int32_t channel-count = 1 D/CCodec (25605): string mime = "audio/raw" D/CCodec (25605): int32_t pcm-encoding = 2 D/CCodec (25605): int32_t sample-rate = 44100 D/CCodec (25605): int32_t channel-mask = 0 D/CCodec (25605): } W/Codec2Client(25605): query -- param skipped: index = 1342179345. W/Codec2Client(25605): query -- param skipped: index = 2415921170. E/FMQ (25605): grantorIdx must be less than 3 E/FMQ (25605): grantorIdx must be less than 3 D/CCodecBufferChannel(25605): [c2.android.raw.decoder#368] Created input block pool with allocatorID 16 => poolID 27 - OK (0) D/BufferPoolAccessor2.0(25605): bufferpool2 0xf67ce388 : 0(0 size) total buffers - 0(0 size) used buffers - 0/5 (recycle/alloc) - 1/2 (fetch/transfer) D/BufferPoolAccessor2.0(25605): Destruction - bufferpool2 0xf67ce388 cached: 0/0M, 0/0% in use; allocs: 5, 0% recycled; transfers: 2, 50% unfetched I/CCodecBufferChannel(25605): [c2.android.raw.decoder#368] Created output block pool with allocatorID 16 => poolID 944 - OK D/CCodecBufferChannel(25605): [c2.android.raw.decoder#368] Configured output block pool ids 944 => OK E/FMQ (25605): grantorIdx must be less than 3 D/CCodecBufferChannel(25605): [c2.android.raw.decoder#368] MediaCodec discarded an unknown buffer I/chatty (25605): uid=10122(com.my.project) NDK MediaCodec_ identical 1 line D/CCodecBufferChannel(25605): [c2.android.raw.decoder#368] MediaCodec discarded an unknown buffer I/hw-BpHwBinder(25605): onLastStrongRef automatically unlinking death recipients D/BufferPoolAccessor2.0(25605): bufferpool2 0xf67d07a8 : 0(0 size) total buffers - 0(0 size) used buffers - 0/5 (recycle/alloc) - 3/6 (fetch/transfer) D/BufferPoolAccessor2.0(25605): evictor expired: 2, evicted: 1
@leongkeng can you recheck with our example. The tests run fine, so I'm not sure, why it shouldn't work
Note that you have to call stop before play again, because the lowlatency player does not know, when a sample is finished playing (no duration available).
Or provide a minimal reproduction example in your own repo and post the link.
@Gustl22
I tried running the example file and the output doesn't seem to be what I needed. It does allow me to play multiple audio but the first audio cuts when the second audio plays. Like you mentioned, I have to call 'stop' before play again means that I cannot have multiple audios playing concurrently?
It used to work in audioplayers: ^0.15.1 version. Where the audio files are able to overlap one another, without cutting off whenever subsequent audios are played at the same time.
This is what i want to achieve, https://drive.google.com/file/d/1bGp0TZdqE9qlamf0560m7pLq3J9I2G5y/view?usp=sharing Its basically 5 'crash' buttons pressed.
This is the Github repo that I found and referrered to for my project https://github.com/kenreilly/flutter-drum-machine-demo
@leongkeng I checked the old implementation. I think this was more a bug than a feature. For each concurrent sound you should use a different instance of an AudioPlayer now. This also ensures that you can release the resources properly after closing the application.
Back then (<= v0.20.x) you could not control the sound in LOW_LATENCY correctly or just pause / stop the last of the sounds which were played concurrently with only one player. This was caused by overwriting the streamId inside the player, although the stream of the old id was still playing. This worked but as soon as the streamId is replaced you could not control the old stream anymore with the player or properly release it.
@luanpotter @spydon correct me if I'm wrong