Skip to content

mbcsalmeida/beep_player

 
 

Repository files navigation

A player for short audio asset files, such as beeps.

On Android, this uses the SoundPool API, with audio attributes set to AudioAttributes.USAGE_ASSISTANCE_SONIFICATION and AudioAttributes.CONTENT_TYPE_SONIFICATION with max streams of 1.

On iOS, this uses the AVAudioPlayer API, with audio category set to AVAudioSessionCategoryAmbient.

Getting Started

Before any calls to BeepPlayer.play, the audio file needs to be loaded first using BeepPlayer.load, otherwise it will silently fail. Don't forget to unload it when no longer needed.

You can also define the volume of the beep with BeepPlayer.playWithVolume. Pass a double to define the volume. Example:

static const BeepFile _beepFile = BeepFile(
    'assets/sounds/beep.wav',
    package: 'package1',
);

@override
void initState() {
    super.initState();
    BeepPlayer.load(_beepFile);
}

@override
void dispose() {
    BeepPlayer.unload(_beepFile);
    super.dispose();
}

@override
Widget build(BuildContext context) {
    ...
}

void _onPressed() {
    BeepPlayer.play(_beepFile);
}

void _onPressedWithVolume(double volume){
  BeepPlayer.playWithVolume(_beepFile, volume);
}

About

A flutter audio player for short audio asset files, such as beeps.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Swift 35.2%
  • Kotlin 28.3%
  • Dart 24.6%
  • Ruby 9.0%
  • Objective-C 2.9%