win32audio

Creator: coderz1093

Last updated:

0 purchases

win32audio Image
win32audio Images

Languages

Categories

Add to Cart

Description:

win32audio

win32audio #
A library to get Audio Devices on Windows.
Also you can get volume and set Master volume or individual application volume
Also includes a utilitary function nativeIconToBytes that can be used for other purposes rather than audio device.

How to use #
Enumerate Devices #
Audio Devices
var audioDevices = <AudioDevice>[];

audioDevices = await Audio.enumDevices(audioDeviceType) ?? [];
copied to clipboard
Audio Mixer
var mixerList = <ProcessVolume>[];

mixerList = await Audio.enumAudioMixer() ?? [];
copied to clipboard
Default Device #
Get
var defaultDevice = AudioDevice();

defaultDevice = (await Audio.getDefaultDevice(audioDeviceType))!;
copied to clipboard
Set
id is COM string
await Audio.setDefaultDevice(audioDevices[0].id, {bool console = false, bool multimedia = true, bool communications = false});
copied to clipboard
Switch to next Audio Device
await Audio.switchDefaultDevice(audioDeviceType, {bool console = false, bool multimedia = true, bool communications = false});
copied to clipboard
Volume #
Volume is double between 0 and 1.
Get
final volume = await Audio.getVolume(audioDeviceType);
copied to clipboard
Set
final volume = await Audio.setVolume(0.5,audioDeviceType);
copied to clipboard
Set Specific app volume:
await Audio.setAudioMixerVolume(mixerList[0].processId, 0.3);
copied to clipboard
Structs/Enums #
class AudioDevice {
String id = "";
String name = "";
String iconPath = "";
int iconID = 0;
bool isActive = false;
}

class ProcessVolume {
int processId = 0;
String processPath = "";
double maxVolume = 1.0;
double peakVolume = 0.0;
}

enum AudioDeviceType {
output,
input,
}
copied to clipboard
Extra Function #
nativeIconToBytes extracts icon either from EXE file or dll file and store it as UInt8List

Map<String, Uint8List?> _audioIcons = {};
_audioIcons = {};
for (var audioDevice in audioDevices) {
if (_audioIcons[audioDevice.id] == null) {
_audioIcons[audioDevice.id] = await nativeIconToBytes(audioDevice.iconPath, iconID: audioDevice.iconID);
}
}
///....
widget: (_audioIcons.containsKey(audioDevices[index].id))
? Image.memory(
_audioIcons[audioDevices[index].id] ?? Uint8List(0),
width: 32,
height: 32,
)
: const Icon(Icons.spoke_outlined),
copied to clipboard
In the same way I've made a class WinIcons() with these functions:
extractFileIcon that extract an asociated icon from any file.
extractWindowIcon which extracts an icon from HWND/ Window Handle
extractIconHandle which extracts an icon from HICON/ Icon Handle.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.