lecle_volume_flutter 0.0.1+1 copy "lecle_volume_flutter: ^0.0.1+1" to clipboard
lecle_volume_flutter: ^0.0.1+1 copied to clipboard

A Flutter plugin to control volume in Android and iOS devices programmatically.

lecle_volume_flutter #

A Flutter plugin to control volume in Android and iOS devices programmatically. Migrate from volume package.

Streams (Works with Android OS only) #

AudioManager.streamVoiceCall       -> Controll IN CALL Volume
AudioManager.streamSystem           -> Controll SYSTEM Volume
AudioManager.streamRing             -> Controll RINGER Volume
AudioManager.streamMusic            -> Controll MEDIA Volume
AudioManager.streamAlarm            -> Controll ALARM Volume
AudioManager.streamNotification     -> Controll NOTIFICATION Volume

Functions and getters #

Volume Buttons will affect this volume when in app #

await Volume.initAudioStream(AudioManager audioManager); // Pass any stream as parameter

Returns maximum possible volume in integers #

await Volume.getMaxVol; // Return an integer on Android and double on iOS

Returns current volume level in integers #

await Volume.getVol; // Return an integer on Android and double on iOS

Set volume for the stream passed to controlVolume() function #

await Volume.setVol({int androidVol = 0, double iOSVol = 0.0, bool showVolumeUI = true});

Max value of i is less than or equal to Volume.getMaxVol.

Usage #

class _MyAppState extends State<MyApp> {
  dynamic maxVol, currentVol; // Value will be int type on Android device and double type on iOS device

  @override
  void initState() {
    super.initState();
    audioManager = AudioManager.streamSystem;
    initAudioStreamType();
    updateVolumes();
  }

  Future<void> initAudioStreamType() async {
    await Volume.initAudioStream(AudioManager.streamSystem);
  }

  void updateVolumes() async {
    // get Max Volume
    maxVol = await Volume.getMaxVol;
    // get Current Volume
    currentVol = await Volume.getVol;
    setState(() {});
  }

  void setVol({int androidVol = 0, double iOSVol = 0.0, bool showVolumeUI = true}) async {
    await Volume.setVol(
      androidVol: androidVol,
      iOSVol: iOSVol,
      showVolumeUI: showVolumeUI,
    );
  }
  
6
likes
130
pub points
80%
popularity

Publisher

verified publisherlecle.vn

A Flutter plugin to control volume in Android and iOS devices programmatically.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on lecle_volume_flutter