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
Was working fine in version < 6.0.0
Beeps are not played
Expected behaviour
Repeated sound (beep) should be played
Steps to reproduce
Approach to play fast repetitive beeps
I am creating List readyPlayers
where I am initialising and storing about (120) players in this list
so whenever activity starts app has to play beep every second and beeps should be always continuous during the activity
this is done by popping 1 player instance from readyPlayers list and playing beep using it
and when player complete the beep it is seek to 0 position and again added to ready players list
Execute flutter run on the code sample
code
a. Beeper.instance.init();
b. await for(int i = 0; i < 100; ++i) await Future.delayed(const Duration(milliseconds: 16), () => Beeper.instance.beepSoft());
c. or Timer.periodic(const Duration(milliseconds: 16), (_) => Beeper.instance.beepSoft());
Audio is not played
Code sample
Code sample
import'package:audioplayers/audioplayers.dart';
classBeeper {
final _beepSoft ='audios/beep_soft.mp3',
_beepSharp ='audios/beep_sharp.mp3',
_beepBackground ='audios/beep_background.mp3';
staticfinalBeeper _instance =Beeper._();
staticBeeperget instance => _instance;
final sw =Stopwatch()..start();
Beeper._();
List<AudioPlayer> readyPlayers = [];
voidinit() async {
AudioLogger.logLevel =AudioLogLevel.error;
final audioCache =AudioCache.instance;
await audioCache.loadAll([_beepSoft, _beepSharp, _beepBackground]);
for (int i =0; i <120; i++) {
final audioPlayer =AudioPlayer();
audioPlayer.audioCache = audioCache;
await audioPlayer.seek(constDuration(milliseconds:20));
audioPlayer.onPlayerComplete.listen((event) async {
await audioPlayer.seek(Duration.zero);
readyPlayers.add(audioPlayer);
});
readyPlayers.add(audioPlayer);
}
}
voidbeepSoft() async {
if (sw.elapsedMilliseconds <36) {
return;
}
sw.reset();
if (readyPlayers.isEmpty) {
return;
}
final ap = readyPlayers.last;
readyPlayers.removeLast();
await ap.play(AssetSource(_beepSoft));
}
voidbeepSharp() async {
if (sw.elapsedMilliseconds <36) {
return;
}
sw.reset();
if (readyPlayers.isEmpty) {
return;
}
final ap = readyPlayers.last;
readyPlayers.removeLast();
await ap.play(AssetSource(_beepSharp));
}
voidbeepBackground() async {
if (sw.elapsedMilliseconds <36) {
return;
}
sw.reset();
if (readyPlayers.isEmpty) {
return;
}
final ap = readyPlayers.last;
readyPlayers.removeLast();
await ap.play(AssetSource(_beepBackground));
}
}
Checklist
Current bug behaviour
Was working fine in version < 6.0.0
Beeps are not played
Expected behaviour
Repeated sound (beep) should be played
Steps to reproduce
Approach to play fast repetitive beeps
I am creating List readyPlayers
where I am initialising and storing about (120) players in this list
so whenever activity starts app has to play beep every second and beeps should be always continuous during the activity
this is done by popping 1 player instance from readyPlayers list and playing beep using it
and when player complete the beep it is seek to 0 position and again added to ready players list
flutter run
on the code samplea.
Beeper.instance.init();
b.
await for(int i = 0; i < 100; ++i) await Future.delayed(const Duration(milliseconds: 16), () => Beeper.instance.beepSoft());
c. or
Timer.periodic(const Duration(milliseconds: 16), (_) => Beeper.instance.beepSoft());
Code sample
Code sample
Affected platforms
Android, iOS, macOS
Platform details
No response
AudioPlayers Version
6.0.0
Build mode
debug, profile, release
Audio Files/URLs/Sources
Archive.zip
Screenshots
No response
Logs
Full Logs
Flutter doctor:
Related issues / more information
No response
Working on PR
no way
The text was updated successfully, but these errors were encountered: