Skip to content

A Flutter plugin to monitor and adjust device volume from 0 to 100%.

Notifications You must be signed in to change notification settings

cheebeez/volume_regulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Volume Regulator

A Flutter plugin to monitor and adjust device volume from 0 to 100%.

flutter platform pub package

Installation

To use this package, add volume_regulator as a dependency in your pubspec.yaml file.

dependencies:
  volume_regulator: ^2.4.0

iOS

To hide the volume HUD edit your AppDelegate.swift and add self.window?.insertSubview(MPVolumeView(), at: 0)

import UIKit
import Flutter
import MediaPlayer

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
    override func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
        self.window?.insertSubview(MPVolumeView(), at: 0)
        GeneratedPluginRegistrant.register(with: self)
        return super.application(application, didFinishLaunchingWithOptions: launchOptions)
    }
}

Simulator does not process all events, unlike a real device.

Usage

// Import package
import 'package:volume_regulator/volume_regulator.dart';

// Set the new volume, between 0-100.
VolumeRegulator.setVolume(50);

// Get the current volume.
VolumeRegulator.getVolume().then((value) {
  print(value);
});

Volume Event

This event is fired when the volume has changed.

VolumeRegulator.volumeStream.listen((value) {
  print(value);
});

Requirements

  • iOS: SDK 10.0 (or later)
  • Android: API Level 23 (or later)

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Please make sure to update tests as appropriate.

About

A Flutter plugin to monitor and adjust device volume from 0 to 100%.

Resources

Stars

Watchers

Forks