i already made voice recorder using flutter_sound,
the sound only play once, maybe someone have try to auto loop when it's play ?
@override
void initState() {
if (widget.voiceofer != null) {
flutterSound.startPlayer(
'/data/user/0/id.captrue.captrue/app_flutter/${widget.voiceofer}');
}
super.initState();
}
using new version of audioplayers 1.1.1 you can use setReleaseMode()
Example:
final player = AudioPlayer();
void playSound() async {
await player.play(AssetSource('sound.mp3'));
}
void loop() {
player.setReleaseMode(ReleaseMode.loop);
}
I recommend to use audioplayers as library who has a build in feature for looping audio.
Link: audioplayers: ^0.14.0
Implementation:
loop the with name of your file.Example:
static AudioCache musicCache;
static AudioPlayer instance;
void playLoopedMusic() async {
musicCache = AudioCache(prefix: "audio/");
instance = await musicCache.loop("bgmusic.mp3");
// await instance.setVolume(0.5); you can even set the volume
}
void pauseMusic() {
if (instance != null) {
instance.pause();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With