audioplayers
audioplayers copied to clipboard
load() and loadall() not working properly
At the start of the app I call the loadall() method but later when i play the sound the following message displays on the terminal:
time to call load() for /data/user/0/com.example.xyz/cache/Sound-1.wav: 1 player=xyz.luan.audioplayers.WrappedSoundPool@31aa630
If the sound is already loaded through loadall() method why is this thing being displayed.
NOTE:
I play the audio by calling its name:
_player.play("Sound-1", mode: PlayerMode.LOW_LATENCY);
I tried something and it seems like it fixed but i want to still report:
void loadAudioAssets() async {
for (String audio in [_soundA, _soundB, _correctSound, _wrongSound]) {
await _player.play(audio, volume: 0, mode: PlayerMode.LOW_LATENCY);
}
}
This function is run when the app starts and then when I play these sounds it doesn't say time to call load() for
and there is nod delay.
Is this the right way to load sounds?
@millionhz interesting, can you please also provide a snippet with your "loadAll()" code? just so I can see and reproduce easily
also, what platform are we talking about? (web, android, ios, macos, and is it device or emulator?)
void loadAudioAssets() {
_player.loadAll([_soundA, _soundB, _correctSound, _wrongSound]);
}
I am running the app on an android device running Android 10
I think it's an issue only with the LOW_LATENCY player, definitely smells like a bug.
I had the same issue. It seems the load
and loadAll
do only the prefetching from the assets and not the loading in the soundpool.
To preload into the soundpool the setUrl(url)
can be used.
Otherwise they are only loaded at the first call to play()
.
I have the same issue, has anyone been able to fix this yet?
I have the same issue, has anyone been able to fix this yet?
Try this:
void loadAudioAssets() async { for (String audio in [_soundA, _soundB, _correctSound, _wrongSound]) { await _player.play(audio, volume: 0, mode: PlayerMode.LOW_LATENCY); } }
Playing all the audio files at the very start of the app with volume: 0
will load the assets.
@millionhz Can you check, is this still a thing with 1.x.x? Thx :)
Edit: Also let's see #1526