A Flutter plugin that allows setting and getting the volume level for different audio types as well as getting current playback type.
To use this package, add tizen_audio_manager
as a dependency in your pubspec.yaml
file.
dependencies:
tizen_audio_manager: ^0.1.1
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);
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();
Use the following code to get currently playing playback type:
final playbackType = await AudioManager.volumeController.currentPlaybackType;
You can get and set the volume level for the following audio types:
enum AudioVolumeType {
system,
notification,
alarm,
ringtone,
media,
call,
voip,
voice,
none
}
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>