Skip to content

Latest commit

 

History

History

tizen_audio_manager

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

tizen_audio_manager

pub package

A Flutter plugin that allows setting and getting the volume level for different audio types as well as getting current playback type.

Usage

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

dependencies:
  tizen_audio_manager: ^0.1.1

Getting and setting the volume level

Get the maximum volume level for alarm media type:

final level = await AudioManager.volumeController.getMaxLevel(AudioVolumeType.alarm);

Get the current level for alarm media type:

final level = await AudioManager.volumeController.getLevel(AudioVolumeType.alarm);

Set new volume level for alarm media type:

final newLevel = 10;
AudioManager.volumeController.setLevel(AudioVolumeType.alarm, newLevel);

Listening to volume changes

You can detect volume changes using AudioManager.volumeController.onChanged.

_subscription = AudioManager.volumeController.onChanged.listen((event) {
  final mediaType = event.type;
  final newLevel = event.level;
});
...
_subscription.cancel();

Getting current playback type

Use the following code to get currently playing playback type:

final playbackType = await AudioManager.volumeController.currentPlaybackType;

Available types

You can get and set the volume level for the following audio types:

enum AudioVolumeType {
  system,
  notification,
  alarm,
  ringtone,
  media,
  call,
  voip,
  voice,
  none
}

Required privileges

In order to set the volume, add the following privileges to your tizen-manifest.xml file:

<privileges>
  <privilege>http://tizen.org/privilege/volume.set</privilege>
</privileges>