XVolume 0.1.1
dotnet add package XVolume --version 0.1.1
NuGet\Install-Package XVolume -Version 0.1.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="XVolume" Version="0.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="XVolume" Version="0.1.1" />
<PackageReference Include="XVolume" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add XVolume --version 0.1.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: XVolume, 0.1.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=XVolume&version=0.1.1
#tool nuget:?package=XVolume&version=0.1.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
XVolume
A cross-platform .NET library for controlling system volume on Windows, macOS, and Linux. Built on .NET Standard 2.0 for maximum compatibility.
Features
- Get and set system volume (0-100%)
- Mute, unmute, and toggle mute state
- Increment and decrement volume by percentage
- Smooth volume transitions with customizable duration
- Query current audio device name
- Support for Windows Core Audio, macOS CoreAudio, ALSA, PulseAudio, and PipeWire
- Lightweight with minimal dependencies
- Thread-safe operations
Installation
dotnet add package XVolume
Usage
using XVolume;
using Microsoft.Extensions.Logging;
// Create with optional logger
using var volume = VolumeSubsystemFactory.Create();
// Basic operations
Console.WriteLine($"Audio System: {volume.Name}");
Console.WriteLine($"Current Device: {volume.CurrentDevice ?? "Unknown"}");
Console.WriteLine($"Current Volume: {volume.Volume}%");
Console.WriteLine($"Muted: {volume.IsMuted}");
// Set volume
volume.Volume = 50;
// Mute operations
volume.Mute();
volume.Unmute();
volume.ToggleMute();
// Adjust volume
volume.IncrementVolume(10); // +10%
volume.DecrementVolume(5); // -5%
// Smooth transitions
await volume.SetVolumeSmooth(75, durationMs: 1000);
Platform Support
- .NET Standard 2.0 compatible
- Works with .NET Framework 4.6.1+, .NET Core 2.0+, and modern .NET versions
Supported Audio Systems
- Windows: Core Audio API (Vista and later)
- macOS: CoreAudio via osascript (macOS 10.15+)
- Linux:
- ALSA (Advanced Linux Sound Architecture)
- PulseAudio
- PipeWire (with PulseAudio compatibility layer)
Prerequisites
Windows/macOS
No additional dependencies required.
Linux
Depending on your audio system:
- ALSA:
sudo apt install alsa-utils
- PulseAudio:
sudo apt install pulseaudio pulseaudio-utils
- PipeWire:
sudo apt install pipewire pipewire-pulse
The library automatically detects and uses the available audio system.
Error Handling
using Microsoft.Extensions.Logging;
// Use a logger for detailed diagnostics
var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole());
var logger = loggerFactory.CreateLogger<Program>();
try
{
using var volume = VolumeSubsystemFactory.Create(logger);
volume.Volume = 50;
}
catch (PlatformNotSupportedException ex)
{
Console.WriteLine($"Platform not supported: {ex.Message}");
}
catch (InvalidOperationException ex)
{
Console.WriteLine($"Audio system not available: {ex.Message}");
}
License
MIT License - see LICENSE file for details.
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
Links
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.